Skip to content

Commit

Permalink
Merge pull request #1147 from 18F/bjs-build-package-upgrades
Browse files Browse the repository at this point in the history
upgrade webpack + related packages
  • Loading branch information
jeremiak authored Jul 10, 2017
2 parents 7e3d2d7 + efa6d89 commit 0f40743
Show file tree
Hide file tree
Showing 4 changed files with 123 additions and 132 deletions.
32 changes: 14 additions & 18 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,8 @@
"scripts": {
"start": "node build/server.js",
"postinstall": "npm run swagger",
"build": "export NODE_ENV=production && npm run build:client && npm run build:server && unset NODE_ENV",
"build:client": "webpack -p --progress --config webpack.client.config.js",
"build:server": "webpack --config webpack.server.config.js",
"watch": "npm run watch:server & npm run watch:client",
"watch:server": "webpack -w --config webpack.server.config.js & nodemon build/server.js",
"watch:client": "webpack -w --progress --config webpack.client.config.js",
"build": "export NODE_ENV=production && webpack -p --progress --config webpack.config.js && unset NODE_ENV",
"watch": "webpack -w --progress --config webpack.config.js & nodemon build/server.js",
"lint": "npm run lint:js && npm run lint:yml",
"lint:js": "eslint src scripts server.js --ignore-path .gitignore || exit 0",
"lint:yml": "yamllint content/**/*.yml || exit 0",
Expand Down Expand Up @@ -73,39 +69,39 @@
"topojson": "^2.2.0"
},
"devDependencies": {
"autoprefixer": "^6.5.4",
"autoprefixer": "^7.1.2",
"babel-cli": "^6.18.0",
"babel-core": "^6.18.2",
"babel-eslint": "^7.1.1",
"babel-jest": "^17.0.2",
"babel-loader": "^6.2.8",
"babel-loader": "^7.1.1",
"babel-preset-es2015": "^6.18.0",
"babel-preset-react": "^6.16.0",
"babel-preset-stage-0": "^6.16.0",
"compression-webpack-plugin": "^0.3.2",
"css-loader": "^0.26.1",
"compression-webpack-plugin": "^0.4.0",
"css-loader": "^0.28.4",
"enzyme": "^2.6.0",
"eslint": "^3.11.1",
"eslint-config-airbnb": "^13.0.0",
"eslint-import-resolver-webpack": "^0.8.1",
"eslint-import-resolver-webpack": "^0.8.3",
"eslint-plugin-babel": "^4.0.0",
"eslint-plugin-import": "^2.2.0",
"eslint-plugin-jsx-a11y": "^2.2.3",
"eslint-plugin-react": "^6.10.0",
"extract-text-webpack-plugin": "^1.0.1",
"extract-text-webpack-plugin": "^2.1.2",
"jest": "^17.0.3",
"json-loader": "^0.5.4",
"node-sass": "^3.13.0",
"node-sass": "^4.5.3",
"nodemon": "^1.11.0",
"postcss-loader": "^1.2.1",
"postcss-loader": "^2.0.6",
"prettier": "^1.4.4",
"react-test-renderer": "^15.5.4",
"sass-loader": "^4.0.2",
"sass-loader": "^6.0.6",
"sinon": "^1.17.6",
"style-loader": "^0.13.1",
"webpack": "1.13.2",
"style-loader": "^0.18.2",
"webpack": "^2.6.1",
"yaml-lint": "0.0.4",
"yaml-loader": "^0.4.0"
"yaml-loader": "^0.5.0"
},
"babel": {
"presets": [
Expand Down
66 changes: 0 additions & 66 deletions webpack.client.config.js

This file was deleted.

109 changes: 109 additions & 0 deletions webpack.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
/* eslint-disable comma-dangle, no-param-reassign, no-var, quote-props */
const fs = require('fs')
const path = require('path')

const autoprefixer = require('autoprefixer')
const CompressionPlugin = require('compression-webpack-plugin')
const ExtractTextPlugin = require('extract-text-webpack-plugin')

const webpack = require('webpack')

const env = process.env.NODE_ENV || 'development'

const clientConfig = {
entry: './src/entry.js',
output: {
path: path.join(__dirname, 'build'),
filename: 'bundle.js',
},
module: {
rules: [
{
test: /\.js$/,
exclude: /node_modules\/(?!autotrack|dom-utils)/,
loader: 'babel-loader',
},
{
test: /\.scss$/i,
use: ExtractTextPlugin.extract({
fallback: 'style-loader',
use: [
'css-loader',
{
loader: 'postcss-loader',
options: {
plugins: [autoprefixer('last 2 versions', '> 5%')],
},
},
{
loader: 'sass-loader',
options: {
outputStyle: 'compressed',
includePaths: ['node_modules'],
},
},
],
}),
},
{
test: /\.ya*ml$/,
use: ['json-loader', 'yaml-loader'],
},
],
},
plugins: [
new CompressionPlugin({
asset: '[path].gz[query]',
algorithm: 'gzip',
test: /\.js$/,
threshold: 10240,
minRatio: 0.8,
}),
new ExtractTextPlugin('app.css'),
new webpack.DefinePlugin({
'process.env': {
NODE_ENV: JSON.stringify(env),
},
}),
],
}

const serverConfig = {
cache: false,
entry: './src/server.js',
output: {
path: path.join(__dirname, 'build'),
filename: 'server.js',
},
target: 'node',
node: {
__dirname: false,
},
externals: fs
.readdirSync('node_modules')
.filter(x => ['.bin'].indexOf(x) === -1)
.reduce((nodeModules, mod) => {
nodeModules[mod] = `commonjs ${mod}`
return nodeModules
}),
module: {
rules: [
{
test: /\.js$/,
exclude: /node_modules\/(?!autotrack|dom-utils)/,
loader: 'babel-loader',
},
{
test: /\.ya*ml$/,
use: ['json-loader', 'yaml-loader'],
},
],
},
plugins: [new webpack.IgnorePlugin(/\.(css|less)$/)],
}

if (env === 'production') {
clientConfig.plugins.push(new webpack.optimize.UglifyJsPlugin())
}

module.exports = [serverConfig, clientConfig]
48 changes: 0 additions & 48 deletions webpack.server.config.js

This file was deleted.

0 comments on commit 0f40743

Please sign in to comment.