-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwebpack.config.js
More file actions
61 lines (59 loc) · 1.59 KB
/
webpack.config.js
File metadata and controls
61 lines (59 loc) · 1.59 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
// noinspection JSValidateTypes
const path = require("path");
const webpack = require("webpack");
const CopyPlugin = require("copy-webpack-plugin");
const DotenvPlugin = require("dotenv-webpack");
const HtmlWebpackPlugin = require("html-webpack-plugin");
module.exports = env => ({
entry: ["babel-polyfill", path.resolve(__dirname, "./src/index.js")],
module: {
rules: [
{
test: /\.(js|jsx)$/,
exclude: /node_modules/,
use: ["babel-loader"]
},
{
test: /\.css$/,
use: ["style-loader", "css-loader"]
},
{
test: /\.(png|jpg)$/,
use: ["url-loader"]
}
]
},
resolve: {
extensions: ["*", ".js", ".jsx"]
},
output: {
path: path.resolve(__dirname, "dist"),
filename: "[name].[hash:8].js",
sourceMapFilename: "[name].[hash:8].map",
chunkFilename: "[name].[hash:8].js",
},
optimization: {
splitChunks: {
chunks: "all"
}
},
plugins: [
new CopyPlugin({
patterns: [{from: "config", to: "config"}],
}),
new HtmlWebpackPlugin({
template: path.resolve(__dirname, "./src/template.html"),
hash: true,
publicPath: "/",
}),
new webpack.EnvironmentPlugin({
NODE_ENV: "development",
}),
...(env.production ? [] : [
new DotenvPlugin(),
]),
],
devServer: {
historyApiFallback: true,
},
});