Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
kvkens committed Apr 27, 2018
1 parent 4e1ffe0 commit 5165409
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 4 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -57,3 +57,4 @@ typings/
# dotenv environment variables file
.env

package-lock.json
7 changes: 5 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "uba-build",
"version": "2.0.0-rc.0",
"version": "2.0.0-rc.1",
"description": "build server plugin for uba",
"main": "index.js",
"bin": {
Expand Down Expand Up @@ -45,11 +45,14 @@
"less-loader": "^4.1.0",
"mini-css-extract-plugin": "^0.4.0",
"minimist": "^1.2.0",
"optimize-css-assets-webpack-plugin": "^4.0.0",
"postcss-flexbugs-fixes": "^3.3.0",
"postcss-loader": "^2.1.4",
"raw-loader": "^0.5.1",
"uglifyjs-webpack-plugin": "^1.2.5",
"url-loader": "^1.0.1",
"webpack": "^4.6.0",
"webpack-merge": "^4.1.2"
}
},
"devDependencies": {}
}
40 changes: 38 additions & 2 deletions src/build.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
const path = require('path');
const chalk = require('chalk');
const glob = require('glob');
const OptimizeCSSAssetsPlugin = require('optimize-css-assets-webpack-plugin');
const UglifyJsPlugin = require('uglifyjs-webpack-plugin');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const webpack = require('webpack');
const merge = require('webpack-merge');
Expand All @@ -18,6 +20,16 @@ const cfg = util.getUbaConfig()();
const config = {
devtool: cfg.devtool ? cfg.devtool : "source-map",
mode: 'production',
optimization: {
minimizer: [
new UglifyJsPlugin({
cache: true,
parallel: true,
sourceMap: true // set to true if you want JS source maps
}),
new OptimizeCSSAssetsPlugin({})
]
},
output: cfg.output,
externals: cfg.externals,
resolve: cfg.resolve,
Expand All @@ -36,7 +48,19 @@ if (cfg.appType === 'single') {
config['entry'] = cfg.entry;
//设置一次HTML插件
config['plugins'].push(new HtmlWebpackPlugin(Object.assign({
template: "./src/index.html"
template: "./src/index.html",
minify: {
removeComments: true,
collapseWhitespace: true,
removeRedundantAttributes: true,
useShortDoctype: true,
removeEmptyAttributes: true,
removeStyleLinkTypeAttributes: true,
keepClosingSlash: true,
minifyJS: true,
minifyCSS: true,
minifyURLs: true
}
}, cfg.html)));
} else if (cfg.appType === 'multi') { //多页模式
let entries = {};
Expand All @@ -49,7 +73,19 @@ if (cfg.appType === 'single') {
template: `./src/pages/${chunk}/index.html`,
chunks: ['manifest', 'vendor', 'test', chunk],
chunksSortMode: "manual",
filename: `${chunk}.html`
filename: `${chunk}.html`,
minify: {
removeComments: true,
collapseWhitespace: true,
removeRedundantAttributes: true,
useShortDoctype: true,
removeEmptyAttributes: true,
removeStyleLinkTypeAttributes: true,
keepClosingSlash: true,
minifyJS: true,
minifyCSS: true,
minifyURLs: true
}
};
config['plugins'].push(new HtmlWebpackPlugin(Object.assign(htmlConfig, cfg.html)));
});
Expand Down

0 comments on commit 5165409

Please sign in to comment.