diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 00000000..44ae5237 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,30 @@ +name: Tester + +on: push + +env: + PRIMARY_NODE_VERSION: 12 + +jobs: + Tester: + name: Run Tester + runs-on: ubuntu-latest + strategy: + matrix: + node-version: [10.x, 12.x, 14.x] + + steps: + - uses: actions/checkout@v1 + - name: Use Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v1 + with: + node-version: ${{ matrix.node-version }} + - name: Install + run: | + yarn --ignore-engines --frozen-lockfile + + - name: Test + run: | + yarn test + env: + CI: true diff --git a/.gitignore b/.gitignore index 3a165975..a03dadca 100644 --- a/.gitignore +++ b/.gitignore @@ -4,4 +4,4 @@ node_modules .vscode demo /lib -src/ +/example/ts diff --git a/bin/Build.js b/bin/Build.js index 171ea8fb..ddfde2b7 100644 --- a/bin/Build.js +++ b/bin/Build.js @@ -1,16 +1,18 @@ +const webpack = require('webpack') +const ora = require('ora') +const chalk = require('chalk') +const rm = require('rimraf') +const path = require('path') +const merge = require('webpack-merge') +const { BundleAnalyzerPlugin } = require('webpack-bundle-analyzer') + module.exports = options => { - const webpack = require('webpack') const config = require('./build/config') - let webpackConfig = require('./build/build') - const ora = require('ora') - const chalk = require('chalk') - const rm = require('rimraf') - const path = require('path') - const merge = require('webpack-merge') - const { BundleAnalyzerPlugin } = require('webpack-bundle-analyzer') - const formatStats = require('./lib/formatStats') const { APP_CONFIG } = config + const formatStats = require('./lib/formatStats') + const logWithExit = require('./lib/logWithExit') + let webpackConfig = require('./build/build') const setting = { test: '测试环境', @@ -41,7 +43,7 @@ module.exports = options => { } if (stats.hasErrors()) { - return console.log('构建出现错误') + return logWithExit('构建出现错误') } console.log() diff --git a/example/appConfig.js b/example/appConfig.js new file mode 100644 index 00000000..25ab15f6 --- /dev/null +++ b/example/appConfig.js @@ -0,0 +1,24 @@ +module.exports = { + // 一般情况下,它的值是 /${prodPathPrefix}/${prodPath} + basename: process.env.NODE_ENV === 'production' ? '/system/ts' : '', + + // 打包出口目录的前缀,注意:不需要以/开头 + prodPathPrefix: 'system', + + // 打包的出口目录(默认dist目录) + prodPath: 'ts', + + // syscode 就是打包出口目录的名称 + syscode: 'ts', + + // 本地测试端口 + port: 3880, + + // 本地代理环境地址 + target: 'https://github.com/', + + // html 文档的标题 + title: 'example', + + isSystem: true, +} diff --git a/example/package.json b/example/package.json new file mode 100644 index 00000000..ac116ff5 --- /dev/null +++ b/example/package.json @@ -0,0 +1,9 @@ +{ + "name": "example", + "version": "1.0.0", + "main": "./src/main.ts", + "license": "MIT", + "devDependencies": { + "typescript": "^3.9.5" + } +} diff --git a/example/src/main.ts b/example/src/main.ts new file mode 100644 index 00000000..732147b9 --- /dev/null +++ b/example/src/main.ts @@ -0,0 +1,5 @@ +interface People { + name: string +} + +console.log('hello world') diff --git a/example/src/template.html b/example/src/template.html new file mode 100644 index 00000000..24ad574e --- /dev/null +++ b/example/src/template.html @@ -0,0 +1,9 @@ + + +
+ + +