forked from brownieboy/react-bootstrap-slider
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwebpack.config.js
More file actions
113 lines (106 loc) · 2.8 KB
/
webpack.config.js
File metadata and controls
113 lines (106 loc) · 2.8 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
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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
/* eslint-env node */
// import path from "path";
// import webpack from "webpack";
// import merge from "webpack-merge";
var path = require("path");
var webpack = require("webpack");
var merge = require("webpack-merge");
const TARGET = process.env.npm_lifecycle_event;
const ROOT_PATH = path.resolve(__dirname);
const srcDir = path.join(__dirname, "src");
var exportModule;
const common = {
entry: {
app: path.resolve(ROOT_PATH) + "/src/js/app.jsx"
},
// resolve: {
// modulesDirectories: ["node_modules", "bower_components"]
// },
resolve: {
alias: {
jquery: path.join(srcDir, "js/stubs/jquery-stub.js")
}
},
module: {
loaders: [
{
test: /\.jsx?$/,
include: [path.resolve(__dirname, "src/js")],
loader: "babel-loader", // "babel-loader" is also a legal name to reference
query: {
presets: ["react", "es2015"]
}
}
]
},
devtool: "source-map"
};
if (TARGET === "buildDemowp") {
exportModule = merge(common, {
entry: {
app: path.resolve(ROOT_PATH) + "/demosrc/js/appbuild.jsx"
},
output: {
path: path.resolve(ROOT_PATH, "demo/js/"),
filename: "slider-bundle.min.js"
},
module: {
loaders: [
{
test: /\.jsx?$/,
include: [path.resolve(__dirname, "demosrc/js")],
loader: "babel-loader", // "babel-loader" is also a legal name to reference
query: {
presets: ["react", "es2015"]
}
}
]
},
plugins: [
// new webpack.optimize.CommonsChunkPlugin("vendor", "vendor.min.js", function(module) {
// return module.resource && module.resource.indexOf(srcDir) === -1;
// })
new webpack.optimize.CommonsChunkPlugin({
name: "vendor",
filename: "vendor.min.js",
minChunks: module => {
const userRequest = module.userRequest;
// module.userRequest returns name of file, including path
return (
userRequest &&
userRequest.match(/\.js$/) &&
userRequest.indexOf("node_modules") >= 0
);
}
}),
new webpack.DefinePlugin({
"process.env": { NODE_ENV: '"production"' } // eslint-disable-line quotes
}),
new webpack.optimize.UglifyJsPlugin({
sourceMap: true,
compress: {
warnings: false
}
}),
new webpack.LoaderOptionsPlugin({
minimize: true,
debug: false
})
]
});
}
if (TARGET === "start" || !TARGET) {
exportModule = merge(common, {
output: {
filename: "src/main.js"
},
devServer: {
noInfo: false,
historyApiFallback: true,
// hot: true,
inline: true
},
plugins: [new webpack.HotModuleReplacementPlugin()]
});
}
module.exports = exportModule;