-
Notifications
You must be signed in to change notification settings - Fork 4
/
webpack.config.js
55 lines (54 loc) · 1.66 KB
/
webpack.config.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
const PATH = require("path");
const WEBPACK = require("webpack");
const HTML_WEBPACK_PLUGIN = require("html-webpack-plugin");
const MINI_CSS_EXTRACT_PLUGIN = require("mini-css-extract-plugin");
const BABEL_MINIFY_WEBPACK_PLUGIN = require("babel-minify-webpack-plugin");
const AUTOPREFIXER = require("autoprefixer");
module.exports = {
entry: "./src/index.js",
output: {
filename: "bundle.[hash].js",
path: PATH.resolve(__dirname, "dist"),
publicPath: "/",
},
resolve: {
modules: [__dirname, "src", "node_modules"],
extensions: ["*", ".js", ".jsx"],
},
module: {
rules: [
{ test: /\.jsx?$/, exclude: /node_modules/, use: "babel-loader" },
{
test: /\.s?css$/,
exclude: /node_modules/,
use: [MINI_CSS_EXTRACT_PLUGIN.loader, "css-loader", "postcss-loader", "sass-loader"],
},
{ test: /\.html$/, use: "html-loader" },
{ test: /\.(png|gif|jpe?g|svg)$/, use: "file-loader" },
],
},
devServer: {
historyApiFallback: true,
},
plugins: [
new HTML_WEBPACK_PLUGIN({
template: "./src/index.html",
filename: "./index.html",
}),
new MINI_CSS_EXTRACT_PLUGIN({
filename: "[name].[contenthash].css",
chunkFilename: "[name].[contenthash].css",
}),
new BABEL_MINIFY_WEBPACK_PLUGIN(
{},
{
comments: false,
}
),
new WEBPACK.LoaderOptionsPlugin({
options: {
postcss: [AUTOPREFIXER()],
},
}),
],
};