-
Notifications
You must be signed in to change notification settings - Fork 13
/
webpack.common.js
63 lines (61 loc) · 1.68 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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
const Path = require('path');
const CleanWebpackPlugin = require('clean-webpack-plugin');
const CopyWebpackPlugin = require('copy-webpack-plugin');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const dest = Path.join(__dirname, './dist');
module.exports = {
entry: {
dashboard: Path.resolve(__dirname, './src/js/dashboard'),
login: Path.resolve(__dirname, './src/js/login'),
logout: Path.resolve(__dirname, './src/js/logout'),
polyfills: Path.resolve(__dirname, './src/js/polyfills')
},
output: {
path: dest,
filename: '[name].[hash].js'
},
plugins: [
new CleanWebpackPlugin([dest], { root: Path.resolve(__dirname, '..') }),
new CopyWebpackPlugin([
{ from: Path.resolve(__dirname, './public'), to: 'public' }
]),
new HtmlWebpackPlugin({
filename: 'index.html',
template: Path.resolve(__dirname, './src/pages/dashboard.html'),
chunks: ['dashboard']
}),
new HtmlWebpackPlugin({
filename: 'login.html',
template: Path.resolve(__dirname, './src/pages/login.html'),
chunks: ['login']
}),
new HtmlWebpackPlugin({
filename: 'logout.html',
template: Path.resolve(__dirname, './src/pages/logout.html'),
chunks: ['logout']
})
],
resolve: {
alias: {
'~': Path.resolve(__dirname, './src')
}
},
module: {
rules: [
{
test: /\.mjs$/,
include: /node_modules/,
type: 'javascript/auto'
},
{
test: /\.(ico|jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2)(\?.*)?$/,
use: {
loader: 'file-loader',
options: {
name: '[path][name].[ext]'
}
}
}
]
}
};