Skip to content

Commit

Permalink
tidy compile script
Browse files Browse the repository at this point in the history
  • Loading branch information
edbrett committed May 16, 2020
1 parent 3dd7c58 commit 86ba7c3
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 19 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
"build": "styleguidist build",
"dev": "webpack --watch --progress",
"compile": "NODE_ENV=production webpack --progress",
"static": "BUILD_MODE=static NODE_ENV=production webpack --progress",
"deploy": "yarn static && yarn build && gh-pages -d styleguide"
"compile:static": "BUILD_MODE=static NODE_ENV=production webpack --progress",
"deploy": "yarn compile:static && yarn build && gh-pages -d styleguide"
},
"dependencies": {
"@artsy/fresnel": "^1.1.0",
Expand Down
33 changes: 16 additions & 17 deletions webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,16 @@ const ImageminPlugin = require('imagemin-webpack-plugin').default;
require('dotenv').config({ silent: true });

const isEnvProduction = process.env.NODE_ENV === 'production';
const isStaticBuild = process.env.BUILD_MODE === 'static';

const config = {
entry: './src/index.js',
mode: process.env.NODE_ENV || 'development',
devtool: !isEnvProduction ? 'eval-source-map' : false,
output: {
path: path.resolve(__dirname, 'dist'),
filename:
process.env.BUILD_MODE === 'static'
? 'gfw-assets.latest.js'
: 'bundle.js',
libraryTarget: process.env.BUILD_MODE === 'static' ? 'var' : 'commonjs2',
filename: isStaticBuild ? 'gfw-assets.latest.js' : 'bundle.js',
libraryTarget: isStaticBuild ? 'var' : 'commonjs2',
},
node: { fs: 'empty', net: 'empty' },
module: {
Expand Down Expand Up @@ -99,17 +97,18 @@ const config = {
}),
],
},
...(isEnvProduction && {
externals: [
'react',
'react-dom',
'classnames',
'lodash',
'prop-types',
'@emotion/core',
'@emotion/styled',
],
}),
...(isEnvProduction &&
!isStaticBuild && {
externals: [
'react',
'react-dom',
'classnames',
'lodash',
'prop-types',
'@emotion/core',
'@emotion/styled',
],
}),
plugins: compact([
new webpack.optimize.ModuleConcatenationPlugin(),
new webpack.HashedModuleIdsPlugin(),
Expand All @@ -123,7 +122,7 @@ const config = {
new webpack.IgnorePlugin(/^\.\/locale$/, /moment$/),
new ImageminPlugin(),
process.env.ANALYZE_BUNDLE && new BundleAnalyzerPlugin(),
process.env.BUILD_MODE === 'static' &&
isStaticBuild &&
new S3Plugin({
directory: 'dist',
exclude: /.*\.html$/,
Expand Down

0 comments on commit 86ba7c3

Please sign in to comment.