-
Notifications
You must be signed in to change notification settings - Fork 25
/
webpack.config.js
executable file
·97 lines (84 loc) · 2.06 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
96
97
const path = require("path");
const Webpack = require("webpack");
const HtmlWebpackPlugin = require("html-webpack-plugin");
console.log(`Running in ${process.env.NODE_ENV || "production"} mode`);
const config = {
entry: "./src/index.js",
output: {
path: path.resolve(__dirname, "./qpm/src"),
filename: "index.min.js"
},
resolve: {
extensions: [".js", ".jsx", ".json"]
},
externals: {
"qilin-manager": "require('../node_modules/qilin-manager')"
},
watchOptions: {
ignored: [
path.resolve(__dirname, "./node_modules"),
path.resolve(__dirname, "./demos"),
path.resolve(__dirname, "./build"),
path.resolve(__dirname, "./cache"),
path.resolve(__dirname, "./qpm"),
path.resolve(__dirname, "./bin")
]
},
devtool: "source-map",
context: __dirname,
target: "node-webkit",
module: {
rules: [
{
test: /\.(jpg|jpeg|png)$/,
use: ["url-loader?limit=1000"]
},
{
test: /\.(woff|woff2|eot|otf|ttf|svg)$/,
use: ["file-loader"]
},
{
test: /\.(js|jsx)$/,
use: ["babel-loader"],
exclude: /(node_modules|bower_components)/
},
{
test: /\.(scss|css)$/,
use: [
"style-loader",
"css-loader",
"resolve-url-loader",
{
loader: "sass-loader",
options: {
sourceMap: true,
sourceMapContents: false
}
}
]
}
]
},
plugins: [
new Webpack.LoaderOptionsPlugin({
options: {
postcss: [require("autoprefixer")],
devServer: {
inline: true
}
}
}),
new HtmlWebpackPlugin({
template: "./src/index.html"
})
]
};
if (process.env.NODE_ENV === "development") {
config.mode = "development";
}
if (process.env.NODE_ENV === "production") {
config.mode = "production";
config.plugins.push(new Webpack.optimize.ModuleConcatenationPlugin());
config.plugins.push(new Webpack.optimize.AggressiveMergingPlugin());
}
module.exports = config;