forked from vfat-io/vfat-tools
-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
81 lines (77 loc) · 2.1 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
73
74
75
76
77
78
79
80
81
const path = require('path')
const globals = require('./globals')
const webpack = require('webpack')
let isProduction
module.exports = (env = {}) => {
isProduction = env.production === true
return {
entry: {
vendor: ['lodash.throttle', 'lodash.debounce', 'dompurify', 'picturefill'],
app: ["babel-polyfill", './src/js/index.js'],
},
output: {
filename: isProduction ? '[name].[chunkhash].js' : '[name].js',
chunkFilename: isProduction ? '[name].[chunkhash].js' : '[name].js',
path: path.resolve(__dirname, 'dist', 'js'),
publicPath: `${globals.PP}/js/`
},
module: {
rules: [{
test: /\.js$/,
use: [{
loader: 'babel-loader',
options: {
presets: [
['@babel/env', {
modules: false
}],
]
}
}],
parser: {
system: true
}
}]
},
plugins: [
new webpack.DefinePlugin({
PP: JSON.stringify(''),
SITE_TITLE: JSON.stringify(globals.SITE_TITLE),
DESCRIPTION: JSON.stringify(globals.DESCRIPTION),
SITE_URL: JSON.stringify(globals.SITE_URL),
DEVELOPER_NAME: JSON.stringify(globals.DEVELOPER_NAME),
DEVELOPER_URL: JSON.stringify(globals.DEVELOPER_URL),
GOOGLE_ANALYTICS_ID: JSON.stringify(globals.GOOGLE_ANALYTICS_ID)
})
],
optimization: {
splitChunks: {
cacheGroups: {
commons: {
test: /[\\/]node_modules[\\/]/,
name: 'vendor',
chunks: 'all'
}
}
}
},
resolve: {
alias: {
dist: globals.Dir.dist,
src: globals.Dir.src,
css: globals.Dir.css,
js: globals.Dir.js,
utils: globals.Dir.utils,
static: globals.Dir.static,
images: globals.Dir.images,
videos: globals.Dir.images,
vendor: globals.Dir.vendor,
views: globals.Dir.views,
pages: globals.Dir.pages,
partials: globals.Dir.partials,
},
symlinks: false
},
devtool: isProduction ? '' : 'eval'
}
}