webpack.dll.conf.js
2.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
const webpack = require('webpack');
var path = require('path');
let utils = require('./utils');
let config = require('./config')
const os = require('os');
const UglifyJsparallelPlugin = require('webpack-uglify-parallel');
const AssetsPlugin = require('assets-webpack-plugin');
let ExtractTextPlugin = require('extract-text-webpack-plugin');
const vendors = [
'vue',
'lodash',
'axios',
'vue-router',
'promise-polyfill/promise',
'iview',
'yoho-store',
'yoho-cookie',
'moment',
'buffer',
'bn.js',
'cryptico',
'iview/dist/styles/iview.css'
];
module.exports = {
output: {
path: path.join(__dirname, '/dll'),
filename: '[name].[chunkhash:7].js',
library: '[name]_[chunkhash]',
publicPath: process.env.NODE_ENV === 'production'
? config.build.assetsPublicPath
: config.dev.assetsPublicPath
},
devtool: config.build.productionSourceMap ? '#source-map' : false,
entry: {
vendor: vendors,
},
resolve: {
alias: {
vue$: 'vue/dist/vue.esm.js'
}
},
module: {
rules: utils.styleLoaders({
sourceMap: config.build.productionSourceMap,
extract: true
}).concat([
{
test: /\.(woff2?|eot|ttf|otf|svg)(\?.*)?$/,
loader: 'ignore-file-loader',
options: {
limit: 10000,
name: utils.assetsPath('fonts/[name].[hash:7].[ext]')
}
}])
},
plugins: [
new webpack.DllPlugin({
path: path.join(__dirname, '/dll/manifest.json'),
name: '[name]_[chunkhash]',
context: __dirname,
}),
new webpack.DefinePlugin({
'process.env': config.build.env
}),
new UglifyJsparallelPlugin({
workers: os.cpus().length,
mangle: true,
compress: {
warnings: false
},
comments: false,
sourceMap: true
}),
new webpack.IgnorePlugin(/^\.\/locale$/, /moment$/),
new AssetsPlugin({
filename: 'bundle-config.json',
prettyPrint: true,
path: path.join(__dirname, '/dll/')
}),
new ExtractTextPlugin({
filename: '[name].[contenthash:7].css'
})
],
};