Skip to content

Instantly share code, notes, and snippets.

@jonjaques
Created September 1, 2017 14:41
Show Gist options
  • Save jonjaques/449e00269f8dc311396f7ef2511927ce to your computer and use it in GitHub Desktop.
Save jonjaques/449e00269f8dc311396f7ef2511927ce to your computer and use it in GitHub Desktop.
const webpack = require('webpack')
const path = require('path')
module.exports = [
build('browser'),
build('server')
]
function build(env = 'browser') {
let config = {}
config.devtool = 'cheap-source-map'
config.context = path.resolve('app')
config.entry = ['babel-polyfill', './index.js']
config.output = {
path: path.resolve('public'),
filename: 'app.js'
}
config.externals = {
jquery: 'jQuery'
}
config.module = {
loaders: [
{
loader: 'babel-loader',
test: /\.jsx?/,
include: path.resolve('app')
}
]
}
// for debug
config.plugins = [
new webpack.NamedModulesPlugin()
]
if (env === 'server') {
config.entry = config.entry.slice(1)
config.output.filename = 'server.js'
config.output.libraryTarget = 'commonjs2'
config.target = 'node'
config.node = false
}
return config
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment