-
Notifications
You must be signed in to change notification settings - Fork 4
/
webpack.common.js
66 lines (64 loc) · 1.72 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
64
65
66
/* eslint-disable */
let path = require('path');
let HtmlWebpackPlugin = require('html-webpack-plugin');
let staticPath = path.resolve(__dirname, 'project', 'static');
module.exports = {
resolve: {
alias: {
base: path.resolve(staticPath, 'src'),
},
extensions: ['.js', '.jsx']
},
entry: {
index: path.resolve(staticPath, 'src', 'index.jsx'),
account: path.resolve(staticPath, 'src', 'pages', 'AccountPage.jsx'),
compose: path.resolve(staticPath, 'src', 'pages', 'ComposePage.jsx'),
home: path.resolve(staticPath, 'src', 'pages', 'HomePage.jsx'),
roadmap: path.resolve(staticPath, 'src', 'pages', 'RoadmapPage.jsx'),
information: path.resolve(staticPath, 'src', 'pages', 'InformationPage.jsx'),
},
output: {
path: path.resolve(staticPath, 'dist'),
chunkFilename: '[chunkhash].bundle.js',
filename: '[name].[contenthash].js'
},
optimization: {
splitChunks: {
chunks: 'all',
cacheGroups: {
vendor: {
test: /[\\/]node_modules[\\/]/,
name: 'vendors',
chunks: 'initial',
reuseExistingChunk: true
}
}
}
},
plugins: [
new HtmlWebpackPlugin({
filename: path.resolve(__dirname, 'project', 'static', 'index.html'),
template: path.resolve(__dirname, 'project', 'templates', 'layout.html'),
}),
],
module: {
rules: [
{
test: /\.(js|jsx)$/,
exclude: /node_modules/,
loader: 'babel-loader',
},
{
test: /\.(jpg|jpeg|png|gif|svg|ico|pdf)$/,
loader: 'file-loader',
options: {
name: '[name].[ext]',
}
},
{
test: /\.css$/,
use: ['style-loader', 'css-loader'],
},
]
},
};