Skip to content

Commit d3f617a

Browse files
committed
refactor(code): 完善代码逻辑,删掉冗余依赖
1 parent 359fa51 commit d3f617a

File tree

11 files changed

+1705
-1339
lines changed

11 files changed

+1705
-1339
lines changed

build/webpack.dll.conf.js renamed to build/dll-build.js

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
const path = require('path');
22
const utils = require('./utils');
33
const webpack = require('webpack');
4+
const chalk = require('chalk');
45
const CleanWebpackPlugin = require('clean-webpack-plugin');
56
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
67
const OptimizeCSSAssetsPlugin = require('optimize-css-assets-webpack-plugin');
78

89
// dll文件存放的目录
910
const dllPath = '../public/vendor';
1011

11-
module.exports = {
12+
const dllConf = {
1213
mode: 'production',
1314
entry: {
1415
// 需要提取的库文件
@@ -17,7 +18,7 @@ module.exports = {
1718
vendor: ['vue', 'vue-router', 'vuex', 'normalize.css']
1819
},
1920
module: {
20-
rules:[
21+
rules: [
2122
{
2223
test: /\.(woff2?|eot|ttf|otf)(\?.*)?$/,
2324
loader: 'url-loader',
@@ -69,3 +70,26 @@ module.exports = {
6970
})
7071
]
7172
};
73+
74+
webpack(dllConf, function (err, stats) {
75+
if (err) throw err;
76+
process.stdout.write(stats.toString({
77+
colors: true,
78+
modules: false,
79+
children: false,
80+
chunks: false,
81+
chunkModules: false
82+
}) + '\n\n');
83+
84+
if (stats.hasErrors()) {
85+
const info = stats.toJson();
86+
console.error('\n');
87+
console.error(chalk.magenta('编译打包出错了 ~~~~(>_<)~~~~ \n'));
88+
console.error(chalk.magenta('具体错误信息如下 \n'));
89+
console.error(chalk.red(`${info.errors}.\n`));
90+
console.log(chalk.red(' Build failed with errors.\n'));
91+
process.exit(1);
92+
}
93+
94+
console.log(chalk.cyan(' Build dll complete.\n'));
95+
});

0 commit comments

Comments
 (0)