-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwebpack.base.conf.js
More file actions
126 lines (123 loc) · 4.2 KB
/
Copy pathwebpack.base.conf.js
File metadata and controls
126 lines (123 loc) · 4.2 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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
var path = require('path')
var config = require('./config')
const HtmlWebpackPlugin = require('html-webpack-plugin');
const HtmlWebpackHarddiskPlugin = require('html-webpack-harddisk-plugin');
var webpack = require('webpack')
// var BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin;
process.noDeprecation = true
function resolve(dir) {
return path.join(__dirname, '..', dir)
}
module.exports = {
entry: {
main: './src/main.js',
// editor: './src/editor.js',
vueVendor: ['vue','vue-router','element-ui/lib/theme-default/index.css'],
// reactVendor: ['react','react-dom']
},
output: {
path: path.join(__dirname, "./"),
filename: '[name].js',
publicPath: process.env.NODE_ENV === 'production' ? config.build.assetsPublicPath : config.dev.assetsPublicPath
},
module: {
loaders: [{
test: /\.vue$/,
loader: 'vue-loader',
options: {
cssModules: {
localIdentName: '[name]-[local]-[hash:base64:5]',
camelCase: true
}
}
}, {
test: /\.js$/,
loader: 'babel-loader',
exclude: /node_modules/
}, {
test: /\.(html|tpl)$/,
loader: 'html-loader'
}, {
test: /\.(png|jpg|gif|svg)$/,
loader: 'file-loader',
query: {
name: '[name].[ext]?[hash]'
}
}, {
test: /\.css$/,
loader: 'style-loader!css-loader'
},
{
test: /\.scss$/,
loaders: ["style-loader", "css-loader", "sass-loader"]
},
{
test: /\.(eot|svg|ttf|woff|woff2)(\?\S*)?$/,
loader: 'file-loader'
}]
},
plugins: [
// new BundleAnalyzerPlugin(),
// split vendor js into its own file
// new webpack.optimize.CommonsChunkPlugin({
// name: 'vue-vendor',
// filename: 'vue-vendor.js',
// minChunks: ({ resource }) => (
// resource &&
// resource.indexOf('node_modules') >= 0 &&
// (resource.match(/vue/) || resource.match(/vue-router/) || resource.match(/react/) || resource.match(/react-dom/))
// ),
// }),
// new webpack.optimize.CommonsChunkPlugin({
// name: 'react-vendor',
// filename: 'react-vendor.js',
// minChunks: ({ resource }) => (
// resource &&
// resource.indexOf('node_modules') >= 0 &&
// (resource.match(/react/) || resource.match(/react-dom/))
// ),
// }),
new webpack.optimize.CommonsChunkPlugin({
name: 'vue-vendor',
chunks: ['vueVendor','main']
}),
// new webpack.optimize.CommonsChunkPlugin({
// name: 'react-vendor',
// chunks: ['reactVendor','editor']
// }),
// extract webpack runtime and module manifest to its own file in order to
// prevent vendor hash from being updated whenever app bundle is updated
new webpack.optimize.CommonsChunkPlugin({
name: 'manifest',
minChunks: Infinity
}),
// new webpack.optimize.CommonsChunkPlugin({
// name: 'vueCommon',
// chunks: ['vue','main']
// }),
// new webpack.optimize.CommonsChunkPlugin({
// name: 'reactCommon',
// chunks: ['react','editor']
// }),
new webpack.DefinePlugin({
'process.env': {
NODE_ENV: '"production"'
}
}),
// new HtmlWebpackPlugin({
// alwaysWriteToDisk: true,
// filename: './templates/editor.html',
// inject: false,
// template: path.join(__dirname, './templates/editor.ejs'),
// chunks:['manifest','react-vendor','editor']
// }),
new HtmlWebpackPlugin({
alwaysWriteToDisk: true,
filename: './templates/home.html',
inject: false,
template: path.join(__dirname, './templates/home.ejs'),
chunks:['manifest','vue-vendor','main']
}),
new HtmlWebpackHarddiskPlugin()
]
}