[Build] optimize webpack config

This commit is contained in:
陈嘉涵 2018-05-09 22:44:59 +08:00
parent 26a22fe48f
commit bf05e1e9e1
7 changed files with 11 additions and 20 deletions

View File

@ -2,4 +2,4 @@ es/
lib/ lib/
dist/ dist/
node_modules/ node_modules/
build/**/*.js

View File

@ -1,5 +1,5 @@
const path = require('path'); const path = require('path');
const config = require('./webpack.config.dev.js'); const config = require('./webpack.dev.js');
const isMinify = process.argv.indexOf('-p') !== -1; const isMinify = process.argv.indexOf('-p') !== -1;
module.exports = Object.assign({}, config, { module.exports = Object.assign({}, config, {

View File

@ -1,8 +1,7 @@
const path = require('path'); const path = require('path');
const HtmlWebpackPlugin = require('html-webpack-plugin'); const HtmlWebpackPlugin = require('html-webpack-plugin');
const ProgressBarPlugin = require('progress-bar-webpack-plugin'); const ProgressBarPlugin = require('progress-bar-webpack-plugin');
const isProduction = process.env.NODE_ENV === 'production'; const { VueLoaderPlugin } = require('vue-loader');
const { VueLoaderPlugin } = require('vue-loader')
module.exports = { module.exports = {
mode: 'development', mode: 'development',
@ -17,13 +16,13 @@ module.exports = {
}, },
devServer: { devServer: {
host: '0.0.0.0', host: '0.0.0.0',
stats: 'errors-only',
historyApiFallback: { historyApiFallback: {
rewrites: [ rewrites: [
{ from: /^\/zanui\/vant\/examples/, to: '/examples.html' }, { from: /^\/zanui\/vant\/examples/, to: '/examples.html' },
{ from: /^\/zanui\/vant/, to: '/index.html' } { from: /^\/zanui\/vant/, to: '/index.html' }
] ]
}, }
stats: 'errors-only'
}, },
resolve: { resolve: {
extensions: ['.js', '.vue', '.css'], extensions: ['.js', '.vue', '.css'],

View File

@ -1,8 +1,7 @@
const merge = require('webpack-merge');
const path = require('path'); const path = require('path');
const devConfig = require('./webpack.config.dev.js'); const devConfig = require('./webpack.dev.js');
module.exports = merge(devConfig, { module.exports = Object.assign({}, devConfig, {
mode: 'production', mode: 'production',
output: { output: {
path: path.join(__dirname, '../docs/dist'), path: path.join(__dirname, '../docs/dist'),

View File

@ -14,7 +14,7 @@
], ],
"scripts": { "scripts": {
"bootstrap": "yarn || npm i && cd ./packages/vant-css/ && yarn || npm i && cd ../../", "bootstrap": "yarn || npm i && cd ./packages/vant-css/ && yarn || npm i && cd ../../",
"dev": "npm run build:file && webpack-dev-server --inline --config build/webpack.config.dev.js", "dev": "npm run build:file && webpack-dev-server --inline --config build/webpack.dev.js",
"build:file": "node build/bin/build-entry.js", "build:file": "node build/bin/build-entry.js",
"build:components": "node build/bin/build-components.js --color", "build:components": "node build/bin/build-components.js --color",
"build:vant-css": "gulp build --gulpfile packages/vant-css/gulpfile.js --color", "build:vant-css": "gulp build --gulpfile packages/vant-css/gulpfile.js --color",
@ -23,7 +23,7 @@
"build:changelog": "sh build/bin/build-changelog.sh", "build:changelog": "sh build/bin/build-changelog.sh",
"deploy": "npm run deploy:docs && npm run deploy:cdn && gh-pages -d docs/dist --remote youzan", "deploy": "npm run deploy:docs && npm run deploy:cdn && gh-pages -d docs/dist --remote youzan",
"deploy:cdn": "superman cdn /zanui/vant docs/dist/*.js && superman cdn /zanui/vant/async_en-US docs/dist/async_en-US/*.js && superman cdn /zanui/vant/async_zh-CN docs/dist/async_zh-CN/*.js", "deploy:cdn": "superman cdn /zanui/vant docs/dist/*.js && superman cdn /zanui/vant/async_en-US docs/dist/async_en-US/*.js && superman cdn /zanui/vant/async_zh-CN docs/dist/async_zh-CN/*.js",
"deploy:docs": "rimraf docs/dist && cross-env NODE_ENV=production webpack --progress --hide-modules --config build/webpack.config.prod.js", "deploy:docs": "rimraf docs/dist && cross-env NODE_ENV=production webpack --progress --hide-modules --config build/webpack.doc.js",
"dist": "npm run bootstrap && node build/bin/build-lib.js", "dist": "npm run bootstrap && node build/bin/build-lib.js",
"lint": "./node_modules/.bin/eslint ./packages --ext .js,.vue", "lint": "./node_modules/.bin/eslint ./packages --ext .js,.vue",
"test": "karma start test/karma.conf.js --single-run", "test": "karma start test/karma.conf.js --single-run",
@ -110,7 +110,6 @@
"vue-template-es2015-compiler": "^1.6.0", "vue-template-es2015-compiler": "^1.6.0",
"webpack": "^4.8.1", "webpack": "^4.8.1",
"webpack-cli": "^2.1.3", "webpack-cli": "^2.1.3",
"webpack-dev-server": "3.1.4", "webpack-dev-server": "3.1.4"
"webpack-merge": "^4.1.2"
} }
} }

View File

@ -2,7 +2,7 @@ const path = require('path');
const webpack = require('webpack'); const webpack = require('webpack');
const ProgressBarPlugin = require('progress-bar-webpack-plugin'); const ProgressBarPlugin = require('progress-bar-webpack-plugin');
const { VueLoaderPlugin } = require('vue-loader'); const { VueLoaderPlugin } = require('vue-loader');
const webpackDevConfig = require('../build/webpack.config.dev'); const webpackDevConfig = require('../build/webpack.dev');
function getWebpackConfig(testFileName) { function getWebpackConfig(testFileName) {
return { return {

View File

@ -9464,12 +9464,6 @@ webpack-log@^1.0.1, webpack-log@^1.1.2:
loglevelnext "^1.0.1" loglevelnext "^1.0.1"
uuid "^3.1.0" uuid "^3.1.0"
webpack-merge@^4.1.2:
version "4.1.2"
resolved "https://registry.yarnpkg.com/webpack-merge/-/webpack-merge-4.1.2.tgz#5d372dddd3e1e5f8874f5bf5a8e929db09feb216"
dependencies:
lodash "^4.17.5"
webpack-sources@^1.0.1, webpack-sources@^1.1.0: webpack-sources@^1.0.1, webpack-sources@^1.1.0:
version "1.1.0" version "1.1.0"
resolved "https://registry.yarnpkg.com/webpack-sources/-/webpack-sources-1.1.0.tgz#a101ebae59d6507354d71d8013950a3a8b7a5a54" resolved "https://registry.yarnpkg.com/webpack-sources/-/webpack-sources-1.1.0.tgz#a101ebae59d6507354d71d8013950a3a8b7a5a54"