Skip to content

Commit d88e917

Browse files
committed
build(npm): 升级依赖版本,解决一些版本兼容性问题
1 parent d3f617a commit d88e917

File tree

13 files changed

+5788
-4683
lines changed

13 files changed

+5788
-4683
lines changed

build/dll-build.js

Lines changed: 36 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,30 @@
1-
const path = require('path');
2-
const utils = require('./utils');
3-
const webpack = require('webpack');
4-
const chalk = require('chalk');
5-
const CleanWebpackPlugin = require('clean-webpack-plugin');
6-
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
7-
const OptimizeCSSAssetsPlugin = require('optimize-css-assets-webpack-plugin');
1+
const path = require("path");
2+
const webpack = require("webpack");
3+
const chalk = require("chalk");
4+
const utils = require("./utils");
5+
const { CleanWebpackPlugin } = require("clean-webpack-plugin");
6+
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
7+
const OptimizeCSSAssetsPlugin = require("optimize-css-assets-webpack-plugin");
88

99
// dll文件存放的目录
10-
const dllPath = '../public/vendor';
10+
const dllPath = "../public/vendor";
1111

1212
const dllConf = {
13-
mode: 'production',
13+
mode: "production",
1414
entry: {
1515
// 需要提取的库文件
16-
element: ['element-ui', 'element-ui/lib/theme-chalk/index.css'],
17-
axios: ['axios'],
18-
vendor: ['vue', 'vue-router', 'vuex', 'normalize.css']
16+
element: ["element-ui", "element-ui/lib/theme-chalk/index.css"],
17+
axios: ["axios"],
18+
vendor: ["vue", "vue-router", "vuex", "normalize.css"]
1919
},
2020
module: {
2121
rules: [
2222
{
2323
test: /\.(woff2?|eot|ttf|otf)(\?.*)?$/,
24-
loader: 'url-loader',
24+
loader: "url-loader",
2525
options: {
2626
limit: 10000,
27-
name: '[name].[hash:7].[ext]'
27+
name: "[name].[hash:7].[ext]"
2828
}
2929
},
3030
...utils.styleLoaders({
@@ -36,10 +36,10 @@ const dllConf = {
3636
},
3737
output: {
3838
path: path.join(__dirname, dllPath),
39-
filename: '[name].dll.js',
39+
filename: "[name].dll.js",
4040
// vendor.dll.js中暴露出的全局变量名
4141
// 保持与 webpack.DllPlugin 中名称一致
42-
library: '[name]_[hash]'
42+
library: "[name]_[hash]"
4343
},
4444
optimization: {
4545
minimizer: [
@@ -53,43 +53,45 @@ const dllConf = {
5353
new CleanWebpackPlugin(),
5454
// 设置环境变量
5555
new webpack.DefinePlugin({
56-
'process.env': {
57-
NODE_ENV: 'production'
56+
"process.env": {
57+
NODE_ENV: '"production"'
5858
}
5959
}),
6060
// extract css into its own file
6161
new MiniCssExtractPlugin({
62-
filename: '[name].dll.css'
62+
filename: "[name].dll.css"
6363
}),
6464
// manifest.json 描述动态链接库包含了哪些内容
6565
new webpack.DllPlugin({
66-
path: path.join(__dirname, dllPath, '[name]-manifest.json'),
66+
path: path.join(__dirname, dllPath, "[name]-manifest.json"),
6767
// 保持与 output.library 中名称一致
68-
name: '[name]_[hash]',
68+
name: "[name]_[hash]",
6969
context: process.cwd()
7070
})
7171
]
7272
};
7373

74-
webpack(dllConf, function (err, stats) {
74+
webpack(dllConf, function(err, stats) {
7575
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');
76+
process.stdout.write(
77+
stats.toString({
78+
colors: true,
79+
modules: false,
80+
children: false,
81+
chunks: false,
82+
chunkModules: false
83+
}) + "\n\n"
84+
);
8385

8486
if (stats.hasErrors()) {
8587
const info = stats.toJson();
86-
console.error('\n');
87-
console.error(chalk.magenta('编译打包出错了 ~~~~(>_<)~~~~ \n'));
88-
console.error(chalk.magenta('具体错误信息如下 \n'));
88+
console.error("\n");
89+
console.error(chalk.magenta("编译打包出错了 ~~~~(>_<)~~~~ \n"));
90+
console.error(chalk.magenta("具体错误信息如下 \n"));
8991
console.error(chalk.red(`${info.errors}.\n`));
90-
console.log(chalk.red(' Build failed with errors.\n'));
92+
console.log(chalk.red(" Build failed with errors.\n"));
9193
process.exit(1);
9294
}
9395

94-
console.log(chalk.cyan(' Build dll complete.\n'));
96+
console.log(chalk.cyan(" Build dll complete.\n"));
9597
});

0 commit comments

Comments
 (0)