-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathwebpack.base.config.js
More file actions
100 lines (92 loc) · 2.39 KB
/
webpack.base.config.js
File metadata and controls
100 lines (92 loc) · 2.39 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
const path = require('path');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const packageJson = require('./package.json');
const srcPath = path.join(__dirname, packageJson.config.src_dir_path);
const appPath = path.join(srcPath, '/js/index.js');
// Base options for HtmlWebpackPlugin for generating `index.html`
// This allows production bundle to have possibly different entry file path than webpack-dev-server
const htmlWebpackPluginOptions = {
title: packageJson.name,
template: path.join(srcPath, '/html/index.html'),
favicon: path.join(srcPath, '/img/favicon.png'),
};
// Base options for WebPack
const webpackOptions = {
entry: {
polyfill: '@babel/polyfill',
app: appPath,
},
module: {
rules: [
{
enforce: 'pre',
test: /\.js?$/,
loader: 'eslint-loader',
exclude: /node_modules/,
options: {
fix: true,
},
},
{
test: /\.js$/,
use: 'babel-loader',
exclude: /node_modules/,
},
{
test: /\.css$/,
use: [
MiniCssExtractPlugin.loader,
{ loader: 'css-loader', options: { importLoaders: 1 } },
'postcss-loader',
],
},
{
test: /\.woff(2)?$/,
loader: 'url-loader',
query: {
limit: '10000',
mimetype: 'application/octet-stream',
name: 'font/[name].[hash].[ext]',
},
},
{
test: /\.(jpe?g|png|gif)$/i,
loaders: [
'file-loader?hash=sha512&digest=hex&name=img/[name].[hash].[ext]',
{
loader: 'image-webpack-loader',
query: {
mozjpeg: {
progressive: true,
},
gifsicle: {
interlaced: false,
},
optipng: {
optimizationLevel: 4,
},
pngquant: {
quality: [0.65, 0.9],
speed: 4,
},
},
},
],
},
],
},
plugins: [
new MiniCssExtractPlugin({
filename: 'css/[name].[hash].css',
}),
],
// To suppress this warning when creating the vendor bundle:-
// WARNING in asset size limit: The following asset(s) exceed the recommended size limit.
performance: {
hints: false,
},
};
module.exports = {
htmlWebpackPluginOptions,
webpackOptions,
};