-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathwebpack.config.js
52 lines (47 loc) · 1.4 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
const path = require('path');
const webpack = require('webpack');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const IS_PROD = process.env.NODE_ENV === 'production' ? true : false;
const IS_DEMO = process.env.IS_DEMO === 'demo' ? true : false;
const PUBLIC_PATH = (IS_PROD) ? '//rphansen91.github.io/redux-rtc' : ''
const config = {
entry: IS_DEMO ? "./src/demo.js" : "./src/index.js",
output: {
path: path.resolve(__dirname),
filename: "main.js",
libraryTarget: "commonjs",
publicPath: PUBLIC_PATH
},
plugins: [
new webpack.DefinePlugin({
'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV),
'process.env.IS_DEMO': JSON.stringify(process.env.IS_DEMO),
'process.env.TEST': process.env.TEST
})
],
module: {
loaders: [
{
test: /\.js$/,
loader: "babel-loader",
query: {
presets: ["env"]
},
exclude: /(node_modules|bower_components)/
}
]
}
};
if (IS_DEMO) {
config.output = {
path: path.resolve(__dirname),
filename: "demo.js",
publicPath: PUBLIC_PATH
}
config.plugins.push(new HtmlWebpackPlugin({
template: 'src/index.html',
public: PUBLIC_PATH,
inject: false
}))
}
module.exports = config;