Skip to content

Commit

Permalink
Upgraded webpack to v2
Browse files Browse the repository at this point in the history
  • Loading branch information
rwu823 committed Jan 28, 2017
1 parent bea3f5e commit b87b255
Showing 1 changed file with 24 additions and 17 deletions.
41 changes: 24 additions & 17 deletions webpack.config.js
Original file line number Diff line number Diff line change
@@ -1,21 +1,23 @@
const webpack = require('webpack')
const HtmlWebpackPlugin = require('html-webpack-plugin')

const pkg = require('./package.json')
const { NODE_ENV } = process.env

const webpackEnv = process.env.WEBPACK
const isDemo = webpackEnv === 'demo'
const isProd = process.env.NODE_ENV === 'production'
const isDev = !webpackEnv && !isProd
const isDev = !NODE_ENV
const isProd = NODE_ENV === 'production'
const isDemo = NODE_ENV === 'demo'

const libName = 'react-ripples'

module.exports = {
entry: {
[libName]: isProd
? ['./src']
: ['babel-polyfill', './demo'],
: ['./dev'],
},
output: {
path: isProd ? `${__dirname}/dist` : `${__dirname}/demo`,
path: isProd ? `${__dirname}/npm/dist` : `${__dirname}/gh-pages`,
filename: '[name].js',
library: 'ReactRipples',
libraryTarget: 'umd',
Expand All @@ -25,29 +27,34 @@ module.exports = {
{
test: /\.jsx?$/,
exclude: /(node_modules|bower_components)/,
loader: 'babel',
loader: 'babel-loader',
}
]
},
resolve: {
alias: isDemo ? {
'react': 'react/dist/react.min.js',
'react-dom': 'react-dom/dist/react-dom.min.js',
} : {}
} : { }
},
externals: isProd ? {
...Object.keys(pkg.dependencies).reduce((o, dep)=> {
o[dep] = true
return o
}, {}),

plugins: [
...isProd ? [] : [
new HtmlWebpackPlugin({
template: './dev/index.html',
minify: {
collapseWhitespace: true,
}
})
]
],
externals: isProd ? Object.assign({
react: {
root: 'React',
commonjs: 'React',
commonjs2: 'React',
commonjs: 'react',
commonjs2: 'react',
amd: 'react',
}
} : {},
}) : { },
watch: isDev,
devtool: isDev ? 'eval' : '',
}

0 comments on commit b87b255

Please sign in to comment.