-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
95 lines (88 loc) · 2.08 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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
/* eslint-disable */
var path = require("path");
var webpack = require("webpack");
var ExtractTextPlugin = require("extract-text-webpack-plugin");
var HtmlWebpackPlugin = require("html-webpack-plugin");
var PATHS = {
entry: path.resolve("./src/index"),
output: path.resolve("./dist"),
root: path.resolve("./src"),
};
var config = {
entry: [
"webpack-dev-server/client?http://0.0.0.0:8080", // WebpackDevServer host and port
PATHS.entry,
],
output: {
filename: "bundle.js",
path: PATHS.output,
publicPath: "http://0.0.0.0:8080/",
},
resolve: {
alias: { app: PATHS.root },
},
module: {
rules: [
{
test: /\.(jpg|png|gif|svg)$/,
include: /src\/assets/,
use: ["url?limit=10000&name=assets/images/[name].[ext]", "img-loader"],
},
{
test: /\.js$/,
exclude: /node_modules/,
},
{
test: /\.(css|scss)$/,
use: [
"style-loader",
"css-loader",
"autoprefixer-loader",
"sass-loader",
],
},
{
test: /\.(eot|ttf|woff|woff2|svg)$/,
use: ["file-loader?name=assets/fonts/[name].[ext]"],
},
{
test: /\.(frag|vert|glsl)$/,
use: ["webpack-glsl-loader"],
},
],
},
};
// Dist only configuration
if (process.env.npm_lifecycle_event == "build") {
config.entry = PATHS.entry;
config.output.publicPath = "/";
config.module.rules[2].use = ExtractTextPlugin.extract({
fallbackLoader: "style-loader",
loader: ["css-loader", "autoprefixer-loader", "sass-loader"],
});
config.plugins = [
new ExtractTextPlugin({
filename: "main.css",
disable: false,
allChunks: true,
}),
new HtmlWebpackPlugin({
filename: "index.html",
template: "src/index.html",
favicon: "src/favicon.ico",
inject: false,
}),
];
}
// Dev only configuration
else {
config.devtool = "eval";
config.devServer = {
inline: true,
contentBase: "src",
noInfo: true,
historyApiFallback: true,
publicPath: "/",
};
}
module.exports = config;