-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwebpack.config.js
More file actions
97 lines (93 loc) · 2.26 KB
/
webpack.config.js
File metadata and controls
97 lines (93 loc) · 2.26 KB
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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
const path = require('path')
const HtmlWebPackPlugin = require('html-webpack-plugin')
const MiniCssExtractPlugin = require('mini-css-extract-plugin')
const htmlWebpackPlugin = new HtmlWebPackPlugin({
template: './src/index.html',
filename: './index.html',
title: 'Caching',
favicon: './src/favicon.ico'
})
const miniCssExtractPlugin = new MiniCssExtractPlugin({
filename: '[name].css',
chunkFilename: '[id].css'
})
module.exports = {
entry: './src/index.js',
output: {
path: path.resolve(__dirname, './dist'),
publicPath: '/',
filename: process.env.WEBPACK_MODE ? '[name].[chunkhash].js':'[name].[hash].js'
},
optimization: {
runtimeChunk: 'single',
splitChunks: {
cacheGroups: {
vendor: {
test: /[\\/]node_modules[\\/]/,
name: 'vendors',
chunks: 'all'
}
}
}
},
plugins: [
htmlWebpackPlugin,
miniCssExtractPlugin,
],
devServer: {
host:'000.000.00.00',
port: 8888,
historyApiFallback: true,
disableHostCheck: true
},
resolve: {
extensions: ['.js'],
alias: {
'api': path.resolve(__dirname, './src/api'),
'utils': path.resolve(__dirname, './src/utils'),
'pages': path.resolve(__dirname, './src/pages'),
'stores': path.resolve(__dirname, './src/stores'),
'locales': path.resolve(__dirname, './src/locales'),
'images': path.resolve(__dirname, './src/assets/images'),
'components': path.resolve(__dirname, './src/components'),
'styles': path.resolve(__dirname, './src/assets/stylesheets')
}
},
node: {
fs: 'empty'
},
module: {
rules: [
{
test: /\.yml$/,
use: {
loader: 'js-yaml-loader'
}
},
{
test: [/\.bmp$/, /\.gif$/, /\.svg$/, /\.jpe?g$/, /\.png$/, /\.woff$/, /\.woff2$/, /\.eot$/, /\.ttf$/],
use: [{
loader: 'url-loader',
options: {
limit: 10000,
name: 'images/[hash]-[name].[ext]'
}
}]
},
{
test: /\.(js|jsx)$/,
exclude: /node_modules/,
use: {
loader: 'babel-loader'
}
},
{
test: /\.css$/,
use: [
'style-loader',
'css-loader'
]
}
]
}
};