-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathwebpack.config.js
80 lines (77 loc) · 1.91 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
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
const path = require("path");
const CleanWebpackPlugin = require("clean-webpack-plugin");
const HtmlWebpackPlugin = require("html-webpack-plugin");
const CopyWebpackPlugin = require("copy-webpack-plugin");
const currentDir = __dirname;
const codeBase = path.join(currentDir);
const PRODUCTION = process.env.NODE_ENV === "production";
const plugins = [
new HtmlWebpackPlugin({
title: "Production",
template: "./index.html"
}),
new CopyWebpackPlugin([
{ from: "./favicon", to: "./favicon" },
{ from: "./CNAME", to: "./" }
])
];
if (PRODUCTION) {
plugins.push(new CleanWebpackPlugin(["public"]));
}
const config = {
entry: "./index.js",
devtool: "eval",
plugins: plugins,
performance: { hints: false },
output: {
path: path.resolve(__dirname, "public"),
publicPath: PRODUCTION ? "./" : "/",
filename: "bundle.js"
},
devServer: {
contentBase: "./public",
inline: true,
port: 3000,
disableHostCheck: true
},
module: {
rules: [
{
test: /\.(js|jsx)$/,
exclude: /node_modules/,
use: ["babel-loader"]
},
{
test: /\.scss$/,
use: [
"style-loader",
{
loader: "css-loader",
options: {
importLoaders: 2, // 0 => no loaders (default); 1 => postcss-loader; 2 => postcss-loader, sass-loader
modules: true,
camelCase: "dashes",
localIdentName: "[name]__[local]___[hash:base64:5]"
}
},
"postcss-loader",
"sass-loader"
]
},
{
test: /\.(ttf|eot|svg|woff(2)?)(\?[a-z0-9=&.]+)?$/,
loaders: ["file-loader"],
include: codeBase
},
{
test: /\.(png|jpg?)(\?[a-z0-9=&.]+)?$/,
loaders: ["file-loader"],
include: codeBase
}
]
},
resolve: {
extensions: ["*", ".js", ".jsx"]
}
};
module.exports = config;