Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid including full Lodash build #45

Merged
merged 5 commits into from
Nov 17, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions bin/build.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/usr/bin/env node

// webpack.config.prod.js checks this.
process.env.NODE_ENV = 'production';

// Load the create-react-app config.
const webpackConfigProd = require( 'react-scripts/config/webpack.config.prod' );

// Modify the config according to our needs.

const babelLoader = webpackConfigProd.module.loaders[ 0 ];
if ( babelLoader.loader !== 'babel' ) {
console.error( webpackConfigProd.module.loaders );
throw new Error( 'Couldn\'t find the babel loader config.' );
}

babelLoader.query.plugins = ( babelLoader.query.plugins || [] )
.filter( pluginName => pluginName !== 'lodash' )
.concat( 'lodash' );

console.log( 'Added lodash babel plugin to build' );

// Run the build.
require( 'react-scripts/scripts/build' );
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"private": true,
"devDependencies": {
"babel-eslint": "^7.1.0",
"babel-plugin-lodash": "^3.2.9",
"deep-freeze": "0.0.1",
"eslint": "^3.9.1",
"eslint-plugin-react": "^6.6.0",
Expand Down Expand Up @@ -33,10 +34,10 @@
},
"scripts": {
"start": "react-scripts start",
"build": "npm run lint && react-scripts build",
"build": "npm run lint && node bin/build.js",
"test": "npm run lint && react-scripts test --env=jsdom",
"eject": "react-scripts eject",
"lint": "eslint --ext js,jsx .eslintrc.js src/",
"lint": "eslint --ext js,jsx .eslintrc.js src/ bin/",
"deploy": "npm run build && surge -p ./build -d wpconsole.surge.sh"
}
}