Skip to content

build: update the build system to the latest structure #1729

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Apr 27, 2020
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,8 @@
"root": true,
"extends": [
"plugin:vue-libs/recommended"
]
],
"globals": {
"__DEV__": true
}
}
19 changes: 8 additions & 11 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
.DS_Store
node_modules
TODO.md
lib
docs/.vuepress/dist
examples/**/build.js
types/typings
types/test/*.js
explorations
/docs/.vuepress/dist
/examples/**/build.js
/node_modules
/test/e2e/reports
/test/e2e/screenshots
/types/typings
/types/test/*.js
*.log
test/e2e/reports
test/e2e/screenshots
.DS_Store
83 changes: 0 additions & 83 deletions build/build.main.js

This file was deleted.

92 changes: 0 additions & 92 deletions build/configs.js

This file was deleted.

3 changes: 0 additions & 3 deletions build/rollup.dev.config.js

This file was deleted.

11 changes: 0 additions & 11 deletions build/rollup.logger.config.js

This file was deleted.

10 changes: 8 additions & 2 deletions examples/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ module.exports = {

resolve: {
alias: {
vuex: path.resolve(__dirname, '../src/index.esm.js')
vuex: path.resolve(__dirname, '../src/index.js')
}
},

Expand All @@ -52,6 +52,12 @@ module.exports = {
plugins: [
new VueLoaderPlugin(),
new webpack.HotModuleReplacementPlugin(),
new webpack.NoEmitOnErrorsPlugin()
new webpack.NoEmitOnErrorsPlugin(),
new webpack.DefinePlugin({
__DEV__: JSON.stringify(true),
'process.env': {
NODE_ENV: JSON.stringify(process.env.NODE_ENV),
}
})
]
}
28 changes: 17 additions & 11 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"unpkg": "dist/vuex.js",
"jsdelivr": "dist/vuex.js",
"typings": "types/index.d.ts",
"sideEffects": false,
"files": [
"dist",
"types/index.d.ts",
Expand All @@ -15,18 +16,17 @@
],
"scripts": {
"dev": "node examples/server.js",
"dev:dist": "rollup -wm -c build/rollup.dev.config.js",
"build": "npm run build:main && npm run build:logger",
"build:main": "node build/build.main.js",
"build:logger": "rollup -c build/rollup.logger.config.js",
"build:main": "node scripts/build-main.js",
"build:logger": "node scripts/build-logger.js",
"lint": "eslint src test",
"test": "npm run lint && npm run test:types && npm run test:unit && npm run test:ssr && npm run test:e2e",
"test:unit": "rollup -c build/rollup.dev.config.js && jasmine JASMINE_CONFIG_PATH=test/unit/jasmine.json",
"test:unit": "jasmine JASMINE_CONFIG_PATH=test/unit/jasmine.json",
"test:e2e": "node test/e2e/runner.js",
"test:ssr": "rollup -c build/rollup.dev.config.js && cross-env VUE_ENV=server jasmine JASMINE_CONFIG_PATH=test/unit/jasmine.json",
"test:ssr": "cross-env VUE_ENV=server jasmine JASMINE_CONFIG_PATH=test/unit/jasmine.json",
"test:types": "tsc -p types/test",
"changelog": "conventional-changelog -p angular -i CHANGELOG.md -s",
"release": "bash build/release.sh",
"release": "bash scripts/release.sh",
"docs": "vuepress dev docs",
"docs:build": "vuepress build docs"
},
Expand All @@ -44,29 +44,35 @@
"vue": "^2.0.0"
},
"devDependencies": {
"@rollup/plugin-buble": "^0.21.3",
"@rollup/plugin-commonjs": "^11.1.0",
"@rollup/plugin-node-resolve": "^7.1.3",
"@rollup/plugin-replace": "^2.3.2",
"@types/node": "^13.13.2",
"babel-core": "^6.22.1",
"babel-loader": "^7.1.2",
"babel-plugin-transform-object-rest-spread": "^6.23.0",
"babel-polyfill": "^6.22.0",
"babel-preset-env": "^1.5.1",
"brotli": "^1.3.2",
"chalk": "^4.0.0",
"chromedriver": "^80.0.1",
"conventional-changelog-cli": "^2.0.31",
"cross-env": "^5.2.0",
"cross-spawn": "^6.0.5",
"css-loader": "^2.1.0",
"eslint": "^6.8.0",
"eslint-plugin-vue-libs": "^4.0.0",
"execa": "^4.0.0",
"express": "^4.17.1",
"jasmine": "2.8.0",
"jasmine-core": "2.8.0",
"nightwatch": "^1.3.1",
"nightwatch-helpers": "^1.2.0",
"rollup": "^1.1.0",
"rollup-plugin-buble": "^0.19.6",
"rollup-plugin-replace": "^2.1.0",
"terser": "^3.17.0",
"rollup": "^2.7.2",
"rollup-plugin-terser": "^5.3.0",
"todomvc-app-css": "^2.1.0",
"typescript": "^3.7.2",
"typescript": "^3.8.3",
"vue": "^2.5.22",
"vue-loader": "^15.2.1",
"vue-template-compiler": "^2.5.22",
Expand Down
57 changes: 57 additions & 0 deletions rollup.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
import buble from '@rollup/plugin-buble'
import replace from '@rollup/plugin-replace'
import resolve from '@rollup/plugin-node-resolve'
import commonjs from '@rollup/plugin-commonjs'
import { terser } from 'rollup-plugin-terser'
import pkg from './package.json'

const banner = `/*!
* vuex v${pkg.version}
* (c) ${new Date().getFullYear()} Evan You
* @license MIT
*/`

export function createEntries(configs) {
return configs.map((c) => createEntry(c))
}

function createEntry(config) {
const c = {
input: config.input,
plugins: [],
output: {
banner,
file: config.file,
format: config.format
},
onwarn: (msg, warn) => {
if (!/Circular/.test(msg)) {
warn(msg)
}
}
}

if (config.format === 'umd') {
c.output.name = c.output.name || 'Vuex'
}

c.plugins.push(replace({
__VERSION__: pkg.version,
__DEV__: config.format === 'es' && !config.browser
? `(process.env.NODE_ENV !== 'production')`
: config.env !== 'production'
}))

if (config.transpile !== false) {
c.plugins.push(buble())
}

c.plugins.push(resolve())
c.plugins.push(commonjs())

if (config.minify) {
c.plugins.push(terser({ module: config.format === 'es' }))
}

return c
}
5 changes: 5 additions & 0 deletions rollup.logger.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { createEntries } from './rollup.config'

export default createEntries([
{ input: 'src/plugins/logger.js', file: 'dist/logger.js', name: 'createVuexLogger', format: 'umd', env: 'development' }
])
10 changes: 10 additions & 0 deletions rollup.main.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { createEntries } from './rollup.config'

export default createEntries([
{ input: 'src/index.js', file: 'dist/vuex.esm.browser.js', format: 'es', browser: true, transpile: false, env: 'development' },
{ input: 'src/index.js', file: 'dist/vuex.esm.browser.min.js', format: 'es', browser: true, transpile: false, env: 'production' },
{ input: 'src/index.js', file: 'dist/vuex.esm.js', format: 'es', env: 'development' },
{ input: 'src/index.cjs.js', file: 'dist/vuex.js', format: 'umd', env: 'development' },
{ input: 'src/index.cjs.js', file: 'dist/vuex.min.js', format: 'umd', minify: true, env: 'production' },
{ input: 'src/index.cjs.js', file: 'dist/vuex.common.js', format: 'cjs', env: 'development' }
])
Loading