diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml deleted file mode 100644 index 09b229c..0000000 --- a/.github/workflows/build.yml +++ /dev/null @@ -1,12 +0,0 @@ -name: build -on: push -jobs: - build: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - uses: actions/setup-node@v3 - with: - node-version: '14.x' - - run: npm install - - run: npm run build diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml new file mode 100644 index 0000000..d08998d --- /dev/null +++ b/.github/workflows/deploy.yml @@ -0,0 +1,23 @@ +name: deploy +on: push +jobs: + deploy: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-node@v3 + with: + node-version: '14.x' + - name: Installing + run: yarn install + - name: Building + run: yarn build:demo + - name: Deploying + uses: burnett01/rsync-deployments@7.0.1 + with: + switches: -a --delete --progress + path: demo/ + remote_path: ${{ secrets.SSH_REMOTE_DIR }} + remote_host: ${{ secrets.SSH_HOST }} + remote_user: ${{ secrets.SSH_USER }} + remote_key: ${{ secrets.SSH_PRIVATE_KEY }} diff --git a/package.json b/package.json index e4bdbdc..afe5e34 100644 --- a/package.json +++ b/package.json @@ -20,8 +20,9 @@ }, "main": "./dist/index.js", "scripts": { - "watch": "webpack --mode development --watch", + "watch": "webpack --mode development--name demo --watch", "build": "webpack --mode production", + "build:demo": "webpack --mode production --name demo", "lint": "eslint ./src --fix" }, "devDependencies": { diff --git a/webpack.config.js b/webpack.config.js index 7139ede..fc9514a 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -1,32 +1,37 @@ -const path = require('path'); +const path = require("path"); -module.exports = (_, { mode }) => { - const isDev = mode === 'development'; - const pathRoot =isDev ? path.resolve(__dirname, 'demo') : __dirname; +module.exports = (_, { mode, name }) => { + const isDev = mode === "development"; + const isDemo = name === "demo"; + + const pathRoot = isDemo ? path.resolve(__dirname, "demo") : __dirname; return { resolve: { - extensions: ['.ts'], + extensions: [".ts"], }, - entry: [ - path.resolve(pathRoot, 'src/index.ts'), - ], + entry: [path.resolve(pathRoot, "src/index.ts")], output: { - path: path.resolve(pathRoot, 'dist'), - filename: 'index.js', - libraryTarget: isDev ? undefined : 'commonjs2', + path: path.resolve(pathRoot, "dist"), + filename: "index.js", + libraryTarget: isDemo ? undefined : "commonjs2", + clean: true, }, module: { - rules: [{ - test: /\.ts$/, - use: [{ - loader: 'ts-loader', - options: { - configFile: isDev ? 'tsconfig.dev.json' : undefined, - }, - }], - }], + rules: [ + { + test: /\.ts$/, + use: [ + { + loader: "ts-loader", + options: { + configFile: isDemo ? "tsconfig.dev.json" : undefined, + }, + }, + ], + }, + ], }, - devtool: isDev ? 'inline-source-map' : undefined, + devtool: isDev ? "inline-source-map" : undefined, }; };