Skip to content

Instantly share code, notes, and snippets.

@areai51
Last active March 23, 2019 03:46
Show Gist options
  • Select an option

  • Save areai51/3a9b3f5073a9c275fce9cf272d1d0bf7 to your computer and use it in GitHub Desktop.

Select an option

Save areai51/3a9b3f5073a9c275fce9cf272d1d0bf7 to your computer and use it in GitHub Desktop.
var path = require('path');
var PACKAGE = require('./package.json');
var HtmlWebpackPlugin = require('html-webpack-plugin');
var isProd = process.env.NODE_ENV !== 'dev';
var externals = {};
if (isProd) {
externals = {
react: 'react',
'react-dom': 'reactDOM',
emotion: '@emotion/core',
mobx: 'mobx',
pubSub: 'pubSub',
};
}
var outputPathFragment = isProd ? '../../dist/' + PACKAGE.name : 'dist';
module.exports = {
entry: './app/index.js',
output: {
path: path.resolve(__dirname, outputPathFragment),
filename: `${PACKAGE.name}.app.js`,
publicPath: isProd ? `/${PACKAGE.name}` : ``,
},
externals: externals,
module: {
rules: [
{ test: /\.(js)$/, use: 'babel-loader' }
],
},
mode: 'production',
plugins: [
new HtmlWebpackPlugin({
template: 'app/index.html',
}),
],
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment