-
Notifications
You must be signed in to change notification settings - Fork 1
/
webpack.config.js
83 lines (78 loc) · 1.88 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
var path = require("path");
var webpack = require("webpack");
var merge = require('webpack-merge');
var libraryName = "efficiently";
const TARGET = process.env.npm_lifecycle_event;
console.log("target event is " + TARGET);
var common = {
entry: {
app: './index.js',
},
output: {
path: path.resolve(__dirname, "build"),
publicPath: "/",
filename: "bundle.js"
},
module: {
loaders: [
{
test: /\.jsx?$/,
exclude: /(node_modules|bower_components)/,
loader: 'babel',
query: {
presets: ['react', 'es2015']
}
}
]
},
resolve: {
root: [path.resolve('./src')],
extensions: ['', '.js', '.jsx']
}
}
if (TARGET === 'start') {
module.exports = merge(common, {
devtool: 'eval-source-map',
resolve: {
root: [
path.resolve('./src/efficiently'),
path.resolve('./app')
]
}
})
}
if (TARGET === 'build' || !TARGET) {
module.exports = merge(common, {
entry: {
app: './app/app.jsx',
core: './src/efficiently/efficiently-core.js',
actions: './src/efficiently/efficiently-actions.js',
components: './src/efficiently/efficiently-components.js',
vendor: [
'react',
'react-bootstrap',
'react-redux',
'redux',
'immutable',
'redux-form',
'redux-logger',
'seamless-immutable',
]
},
externals: {
'efficiently-core': 'efficiently-core',
'efficiently-actions': 'efficiently-actions',
'efficiently-components': 'efficiently-components'
},
devtool: 'source-map',
output: {
filename: libraryName + "-[name].js",
library: libraryName + '-[name]',
libraryTarget: 'umd',
umdNamedDefine: true
},
plugins: [
new webpack.optimize.CommonsChunkPlugin(/* chunkName= */"vendor", /* filename= */"vendor.bundle.js")
]
})
}