Created
September 1, 2017 14:41
-
-
Save jonjaques/449e00269f8dc311396f7ef2511927ce to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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