-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathwebpack.config.development.js
More file actions
executable file
·124 lines (122 loc) · 3.46 KB
/
webpack.config.development.js
File metadata and controls
executable file
·124 lines (122 loc) · 3.46 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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
const HtmlWebpackPlugin = require('html-webpack-plugin');
const CleanWebpackPlugin = require('clean-webpack-plugin');
const CopyPlugin = require('copy-webpack-plugin');
const ManifestPlugin = require('webpack-manifest-plugin');
const SWPrecacheWebpackPlugin = require('sw-precache-webpack-plugin');
const webpack = require('webpack');
const path = require('path');
module.exports = {
entry: {
app: ['@babel/polyfill', './src/modules/main/index.js'],
},
node: {
fs: 'empty',
},
devtool: 'eval-source-map',
devServer: {
contentBase: './dist',
hot: true,
historyApiFallback: true,
host: '0.0.0.0',
port: 3000,
inline: true,
},
mode: 'development',
module: {
rules: [
{
test: /\.(js|jsx)$/,
exclude: /node_modules/,
use: {
loader: 'babel-loader',
},
},
{
test: /\.html$/,
use: {
loader: 'html-loader',
},
},
{
test: /\.css$/,
use: ['style-loader', 'css-loader'],
},
{
test: /\.(png|svg|jpg|gif)/,
use: 'file-loader',
},
{
test: /\.(woff(2)?|ttf|eot|svg)(\?v=\d+\.\d+\.\d+)?$/,
use: [
{
loader: 'file-loader',
options: {
name: '[name].[ext]',
outputPath: 'fonts/',
},
},
],
},
],
},
output: {
filename: '[name].[hash].js',
path: path.resolve(__dirname, 'dist'),
publicPath: '/',
},
plugins: [
new SWPrecacheWebpackPlugin({
// By default, a cache-busting query parameter is appended to requests
// used to populate the caches, to ensure the responses are fresh.
// If a URL is already hashed by Webpack, then there is no concern
// about it being stale, and the cache-busting can be skipped.
dontCacheBustUrlsMatching: /\.\w{8}\./,
filename: 'precache-service-worker.js',
logger(message) {
if (message.indexOf('Total precache size is') === 0) {
// This message occurs for every build and is a bit too noisy.
return;
}
console.log(message);
},
minify: true, // minify and uglify the script
navigateFallback: '/index.html',
staticFileGlobsIgnorePatterns: [/\.map$/, /asset-manifest\.json$/],
}),
new CopyPlugin([
{ from: './src/assets', to: 'assets' },
{ from: './src/service-workers', to: 'service-workers' },
{ from: './src/.htaccess' },
{ from: './src/.conf' },
{ from: './src/robots.txt' },
]),
new ManifestPlugin({
fileName: 'asset-manifest.json',
}),
new CleanWebpackPlugin(['dist']),
new HtmlWebpackPlugin({
template: './src/index.html',
filename: './index.html',
}),
new webpack.HotModuleReplacementPlugin(),
new webpack.DefinePlugin({
'process.env': {
NODE_ENV: JSON.stringify(process.env.NODE_ENV),
},
}),
],
resolve: {
alias: {
Images: path.resolve(__dirname, 'src/assets/images'),
SharedComponents: path.resolve(__dirname, 'src/components'),
Config: path.resolve(__dirname, 'src/config'),
Utils: path.resolve(__dirname, 'src/utils'),
Fonts: path.resolve(__dirname, 'src/app/assets/fonts'),
Src: path.resolve(__dirname, 'src'),
Modules: path.resolve(__dirname, 'src/modules'),
Layouts: path.resolve(__dirname, 'src/layouts'),
Root: path.resolve(__dirname, ''),
},
},
target: 'web',
};