forked from vuejs/vuex
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.js
72 lines (62 loc) · 1.61 KB
/
webpack.config.js
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
const fs = require('fs')
const path = require('path')
const webpack = require('webpack')
const { VueLoaderPlugin } = require('vue-loader')
function buildEntry (dirname) {
const lookupDir = path.join(__dirname, dirname)
return fs.readdirSync(lookupDir).reduce((entries, dir) => {
const fullDir = path.join(lookupDir, dir)
const entry = path.join(fullDir, 'app.js')
if (fs.statSync(fullDir).isDirectory() && fs.existsSync(entry)) {
entries[`${dirname}/${dir}`] = ['webpack-hot-middleware/client', entry]
}
return entries
}, {})
}
module.exports = {
mode: 'development',
entry: {
...buildEntry('classic'),
...buildEntry('composition')
},
output: {
path: path.join(__dirname, '__build__'),
filename: '[name].js',
chunkFilename: '[id].chunk.js',
publicPath: '/__build__/'
},
module: {
rules: [
{ test: /\.js$/, exclude: /node_modules/, use: ['babel-loader'] },
{ test: /\.vue$/, use: ['vue-loader'] },
{ test: /\.css$/, use: ['vue-style-loader', 'css-loader'] }
]
},
resolve: {
alias: {
vuex: path.resolve(__dirname, '../src/index.js')
}
},
optimization: {
splitChunks: {
cacheGroups: {
vendors: {
name: 'shared',
filename: 'shared.js',
chunks: 'initial'
}
}
}
},
plugins: [
new VueLoaderPlugin(),
new webpack.HotModuleReplacementPlugin(),
new webpack.NoEmitOnErrorsPlugin(),
new webpack.DefinePlugin({
__DEV__: JSON.stringify(true),
'process.env': {
NODE_ENV: JSON.stringify(process.env.NODE_ENV)
}
})
]
}