This repository was archived by the owner on Jan 2, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathwebpack.config.js
More file actions
75 lines (67 loc) · 1.61 KB
/
webpack.config.js
File metadata and controls
75 lines (67 loc) · 1.61 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
var path = require("path")
var webpack = require("webpack")
var mergeWebpackConfig = require("webpack-merge")
var ExtractTextPlugin = require("extract-text-webpack-plugin")
var TARGET = process.env.npm_lifecycle_event
var config = {}
var commonConfig = {
entry: [
"./src/main.jsx"
],
output: {
path: path.join(__dirname, "dist"),
filename: "bundle.js",
publicPath: "/static/"
},
module: {
loaders: [{
test: /\.jsx?/,
exclude: /node\_modules/,
loaders: ["babel"]
}]
}
}
if (TARGET === "dev:start" || ! TARGET) {
config = {
entry: [
"webpack-dev-server/client?http://localhost:3200",
"webpack/hot/only-dev-server",
"./src/main.jsx"
],
module: {
loaders: [{
test: /\.jsx?/,
exclude: /node\_modules/,
loaders: ["react-hot", "babel"]
}, {
test: /\.css$/,
loaders: ["style", "css"],
include: path.join(__dirname, "src")
}]
},
plugins: [
new webpack.HotModuleReplacementPlugin()
],
devtool: "source-map"
}
}
if (TARGET === "demo:start" || TARGET === "prod:start"
|| TARGET === "demo:build" || TARGET === "prod:build" || TARGET === "build") {
config = {
module: {
loaders: [{
test: /\.css$/,
loader: ExtractTextPlugin.extract("style", "css"),
include: path.join(__dirname, "src")
}]
},
plugins: [
// Output extracted CSS to a file
new ExtractTextPlugin("styles.css")
]
}
if (TARGET.match(/^demo.*/gi)) {
config.devtool = "source-map"
}
}
module.exports = mergeWebpackConfig(commonConfig, config)