-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
41 lines (38 loc) · 945 Bytes
/
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
const webpack = require('webpack')
const pkg = require('./package.json')
const webpackEnv = process.env.WEBPACK
const IS_DEMO = webpackEnv === 'demo'
const IS_PROD = process.env.NODE_ENV === 'production'
const IS_DEV = !webpackEnv && !IS_PROD
const libName = 'index'
module.exports = {
entry: {
[libName]: IS_PROD
? ['./src']
: ['babel-polyfill', './demo'],
},
output: {
path: IS_PROD ? `${__dirname}/dist` : `${__dirname}/demo`,
filename: '[name].js',
library: 'ReactInputValid',
libraryTarget: 'umd',
},
module: {
loaders: [
{
test: /\.jsx?$/,
exclude: /(node_modules|bower_components)/,
loader: 'babel',
}
]
},
resolve: {
alias: IS_DEMO ? {
'react': 'react/dist/react.min.js',
'react-dom': 'react-dom/dist/react-dom.min.js',
} : {}
},
externals: IS_PROD ? {/*TODO*/} : {},
watch: IS_DEV,
devtool: IS_DEV ? 'eval' : '',
}