forked from keyteki/keyteki
-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.common.js
47 lines (46 loc) · 1.59 KB
/
webpack.common.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
const path = require('path');
const webpack = require('webpack');
const { CleanWebpackPlugin } = require('clean-webpack-plugin');
const HtmlWebpackPlugin = require('html-webpack-plugin');
module.exports = {
resolve: { extensions: ['.js', '.jsx'] },
plugins: [
new CleanWebpackPlugin(),
new HtmlWebpackPlugin({
template: './views/index.pug',
inject: true
}),
new webpack.ProvidePlugin({
$: 'jquery',
jQuery: 'jquery'
})
],
output: {
path: path.resolve(__dirname, 'dist'),
publicPath: '/'
},
optimization: {
moduleIds: 'hashed',
runtimeChunk: 'single',
splitChunks: {
cacheGroups: {
vendor: {
test: /[\\/]node_modules[\\/]/,
name: 'vendor',
chunks: 'all'
}
}
}
},
module: {
rules: [
{ test: /\.jsx?/, exclude: /node_modules/, loader: 'babel-loader' },
{ test: /.(png|woff(2)?|eot|ttf|svg)(\?[a-z0-9=.]+)?$/, use: 'url-loader?limit=25000' },
{ test: /\.css$/, use: ['style-loader', 'css-loader'] },
{ test: /\.less$/, use: ['style-loader', 'css-loader', 'less-loader'] },
{ test: /\.scss$/, use: ['style-loader', 'css-loader', 'sass-loader'] },
{ test: /\.json/, exclude: /node_modules/, type: 'javascript/auto', use: [require.resolve('json-loader')] },
{ test: /\.pug$/, include: path.join(__dirname, 'views'), loaders: ['pug-loader'] }
]
}
};