-
Notifications
You must be signed in to change notification settings - Fork 6
/
webpack.config.babel.js
86 lines (77 loc) · 2.21 KB
/
webpack.config.babel.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
/* eslint-env node */
import path from "path";
import webpack from "webpack";
import merge from "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"]
// },
module: {
loaders: [{
test: /\.jsx?$/,
include: [path.resolve(__dirname, "src/js")],
loader: "babel", // "babel-loader" is also a legal name to reference
query: {
presets: ["react", "es2015"]
}
}]
},
devtool: "source-map"
};
if (TARGET === "buildDemo") {
exportModule = merge(common, {
entry: {
app: path.resolve(ROOT_PATH) + "/demosrc/js/app.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", // "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.UglifyJsPlugin({
compress: {
warnings: false
}
})
]
});
}
if (TARGET === "start" || !TARGET) {
exportModule = merge(common, {
output: {
filename: "src/main.js"
},
devServer: {
colors: true,
noInfo: false,
historyApiFallback: true,
// hot: true,
inline: true,
progress: true
},
plugins: [
new webpack.HotModuleReplacementPlugin()
]
});
}
export default exportModule;