spaz-web
Version:
(Deprecated) Web App Microframework for building React SPA's with Express API backends
76 lines (70 loc) • 1.63 kB
JavaScript
let webpack = require('webpack')
let path = require('path')
const NODE_ENV = process.env.NODE_ENV || 'production'
const BUILD_DIR = path.resolve(__dirname, 'assets')
const CLIENT_APP_DIR = path.resolve(__dirname, 'client')
let config = {
entry: {
main: [
'babel-polyfill',
CLIENT_APP_DIR + '/entry.js'
]
},
module: {
loaders: [
{ test: /\.json$/, loader: 'json' },
{
test: /\.js/,
include: CLIENT_APP_DIR,
loader: 'babel',
query: {
presets: ['es2015', 'stage-0', 'react']
}
}
]
},
output: {
path: BUILD_DIR,
publicPath: '/assets/',
filename: '[name].bundle.js'
},
devServer: {
port: 5000,
contentBase: 'assets',
proxy: {
'/api*': {
target: 'http://localhost:3000',
secure: false
}
}
},
plugins: [
new webpack.DefinePlugin({
'process.env': {
NODE_ENV: JSON.stringify(NODE_ENV),
FEATURE_GROUPS: JSON.stringify(!!process.env.FEATURE_GROUPS)
}
}),
new webpack.DefinePlugin({
'__DEV__': (process.env.NODE_ENV !== 'production')
})
]
}
let isProdBuild = (
process.argv.indexOf('--production') !== -1 ||
process.argv.indexOf('-p') !== -1
)
config.plugins = config.plugins.concat(!isProdBuild ? [] : [
new webpack.optimize.DedupePlugin(),
new webpack.optimize.UglifyJsPlugin({
compress: {
screw_ie8: true, // please don't use IE8
unsafe: true,
warnings: false // don't puke warnings when drop code
},
mangle: {
screw_ie8: true
}
})
])
module.exports = config