Skip to content

Commit

Permalink
Merge pull request #27 from Toilal/webpack-parallel-build
Browse files Browse the repository at this point in the history
wip(build): use parallel build for vue2/vue3
  • Loading branch information
FranckFreiburger authored Mar 9, 2021
2 parents bf8a29b + c320977 commit ae53bb9
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
17 changes: 13 additions & 4 deletions build/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@ const pkg = require('../package.json');

const distPath = Path.resolve(__dirname, '..', 'dist');

module.exports = (env = {}, { mode = 'production' }) => {
const configure = ({name, vueVersion}) => (env = {}, { mode = 'production', configName }) => {
if (configName && configName.includes(name)) {
return {name}
}

const isProd = mode === 'production';

Expand All @@ -25,15 +28,15 @@ module.exports = (env = {}, { mode = 'production' }) => {
const {
targetsBrowsers = 'defaults',
noPresetEnv = !isProd,
noCompress = !isProd,
vueVersion = '3',
noCompress = !isProd
} = env;

const genSourcemap = false;

console.log('config', { targetsBrowsers, noPresetEnv, noCompress, genSourcemap, vueVersion });

return {
name,
entry: [
'regenerator-runtime',
Path.resolve(__dirname, '../src/index.ts'),
Expand Down Expand Up @@ -156,7 +159,7 @@ ${ pkg.name } v${ pkg.version }
@description ${ pkg.description }.
@author ${ pkg.author.name } <${ pkg.author.email }>
@license ${ pkg.license }
`.trim()),
`.trim()),
],
resolve: {
extensions: [".ts", ".js"],
Expand Down Expand Up @@ -300,3 +303,9 @@ ${ pkg.name } v${ pkg.version }
}
}

let configs = [
{name: 'vue2', vueVersion: '2' },
{name: 'vue3', vueVersion: '3' }
]

module.exports = configs.map(configure)
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"testVue2": "cd test && cross-env VUE_VERSION=2 yarn run start",
"tests": "jest --runInBand \"tests/.*\\.test.js\"",
"dev": "webpack --mode=development --config ./build/webpack.config.js --progress --watch",
"build": "cross-env-shell webpack --mode=production --config ./build/webpack.config.js --progress --env targetsBrowsers=\\\"$npm_package_browserslist\\\" && cross-env-shell webpack --mode=production --config ./build/webpack.config.js --progress --env vueVersion=\\\"2\\\" --env targetsBrowsers=\\\"$npm_package_browserslist\\\"",
"build": "cross-env-shell webpack --mode=production --config ./build/webpack.config.js --progress --env targetsBrowsers=\\\"$npm_package_browserslist\\\"",
"docs": "cross-env-shell node build/evalHtmlComments.js README.md $npm_package_version && node build/evalHtmlComments.js docs/examples.md $npm_package_version && typedoc --plugin typedoc-plugin-markdown --mode file --tsconfig ./build/tsconfig.json --inputFiles ./src/index.ts --out ./docs/api --readme none --stripInternal --namedAnchors true",
"pushDocs": "yarn run docs && git add docs/ && cross-env-shell git commit -m \\\"chore(docs): v$npm_package_version API docs & examples \\\" docs",
"release": "standard-version --header \"\""
Expand Down Expand Up @@ -78,6 +78,7 @@
"puppeteer": "^8.0.0",
"source-map-explorer": "2.5.2",
"standard-version": "^9.1.1",
"terser-webpack-plugin": "^5.1.1",
"ts-loader": "^8.0.17",
"typedoc": "0.19.2",
"typedoc-plugin-markdown": "3.1.1",
Expand Down

0 comments on commit ae53bb9

Please sign in to comment.