-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.common.js
104 lines (101 loc) · 3.19 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
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
const path = require("path");
const HtmlWebpackPlugin = require("html-webpack-plugin");
const srcPath = path.resolve(__dirname, "src");
const distPath = path.resolve(__dirname, "dist");
const publicPath = path.resolve(__dirname, "public");
const vendors = [
];
module.exports = {
entry: {
bundle: ["babel-polyfill", path.resolve(srcPath, "index.js")],
vendors
},
watchOptions: {
ignored: /node_modules/
},
output: {
path: distPath,
filename: "[name].[hash].bundle.js",
chunkFilename: "[name].[chunkhash].bundle.js",
publicPath: "/"
},
optimization: {
splitChunks: {
cacheGroups: {
vendor: {
test: /[\\/]node_modules[\\/]/,
name: "vendors",
chunks: "all",
enforce: true
}
}
},
runtimeChunk: false
},
module: {
rules: [
{
test: /\.(js|jsx)$/,
include: srcPath,
loader: {
loader: "babel-loader",
query: {
presets: ['es2015', 'react']
}
},
},
{
test: /\.(jpg|png|gif)$/,
include: srcPath,
loader: "file-loader"
},
{
test: /\.svg$/,
include: srcPath,
use: [
{
loader: "babel-loader",
},
{
loader: "svg-react-loader",
options: {
svgo: {
plugins: [
{ cleanupEnableBackground: true },
{ collapseGroups: true },
{ convertTransform: true },
{ removeComments: true },
{ removeEmptyAttrs: true },
{ removeEmptyContainers: true },
{ removeEmptyText: true },
{ removeHiddenElems: true },
{ removeMetadata: true },
{ removeUnknownsAndDefaults: true },
{ removeUselessDefs: true },
{ removeUselessStrokeAndFill: true }
]
}
}
}
]
}
]
},
plugins: [
new HtmlWebpackPlugin({
template: path.resolve(publicPath, "index.html"),
filename: "index.html",
// favicon: path.resolve(publicPath, "favicon.ico"),
title: "SVGator",
inject: true,
minify: {
collapseInlineTagWhitespace: true,
removeComments: true,
removeRedundantAttributes: true
}
})
]
// node: {
// fs: 'empty',
// },
};