Skip to content

Commit

Permalink
Rework build commands to use correct NODE_ENV for feature flags
Browse files Browse the repository at this point in the history
  • Loading branch information
talldan committed Jan 15, 2019
1 parent 0c21fc2 commit 4cb0a39
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@
"clean:packages": "rimraf ./packages/*/build ./packages/*/build-module ./packages/*/build-style",
"prebuild:packages": "npm run clean:packages && lerna run build && cross-env INCLUDE_PACKAGES=babel-plugin-import-jsx-pragma,postcss-themes,jest-console SKIP_JSX_PRAGMA_TRANSFORM=1 node ./bin/packages/build.js",
"build:packages": "cross-env EXCLUDE_PACKAGES=babel-plugin-import-jsx-pragma,jest-console,postcss-themes node ./bin/packages/build.js",
"build": "npm run build:packages && cross-env NODE_ENV=production webpack",
"build": "npm run build:packages && webpack",
"check-engines": "wp-scripts check-engines",
"check-licenses": "concurrently \"wp-scripts check-licenses --prod --gpl2\" \"wp-scripts check-licenses --dev\"",
"precheck-local-changes": "npm run docs:build",
Expand All @@ -169,13 +169,13 @@
"lint-pkg-json": "wp-scripts lint-pkg-json ./packages",
"lint-css": "wp-scripts lint-style '**/*.scss'",
"lint-css:fix": "npm run lint-css -- --fix",
"package-plugin": "./bin/build-plugin-zip.sh",
"package-plugin": "cross-env NODE_ENV=plugin ./bin/build-plugin-zip.sh",
"postinstall": "npm run check-licenses && npm run build:packages",
"pot-to-php": "./bin/pot-to-php.js",
"precommit": "lint-staged",
"publish:check": "npm run build:packages && lerna updated",
"publish:dev": "npm run build:packages && lerna publish --npm-tag next",
"publish:prod": "npm run build:packages && lerna publish",
"publish:check": "cross-env NODE_ENV=production npm run build:packages && lerna updated",
"publish:dev": "cross-env NODE_ENV=production npm run build:packages && lerna publish --npm-tag next",
"publish:prod": "cross-env NODE_ENV=production npm run build:packages && lerna publish",
"test": "npm run lint && npm run test-unit",
"pretest-e2e": "concurrently \"./bin/reset-e2e-tests.sh\" \"npm run build\"",
"test-e2e": "wp-scripts test-e2e --config test/e2e/jest.config.json",
Expand Down
6 changes: 4 additions & 2 deletions webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,10 @@ gutenbergPackages.forEach( ( name ) => {
};
} );

const isDevelopment = process.env.NODE_ENV === 'development';
const isPlugin = process.env.NODE_ENV === 'plugin';
const isProduction = process.env.NODE_ENV === 'production';
const mode = isProduction ? 'production' : 'development';
const mode = isProduction || isPlugin ? 'production' : 'development';

const config = {
mode,
Expand Down Expand Up @@ -167,7 +169,7 @@ const config = {
process.env.GUTENBERG_BUNDLE_ANALYZER && new BundleAnalyzerPlugin(),
// GUTENBERG_LIVE_RELOAD_PORT global variable changes port on which live reload works
// when running watch mode.
! isProduction && new LiveReloadPlugin( { port: process.env.GUTENBERG_LIVE_RELOAD_PORT || 35729 } ),
isDevelopment && new LiveReloadPlugin( { port: process.env.GUTENBERG_LIVE_RELOAD_PORT || 35729 } ),
].filter( Boolean ),
stats: {
children: false,
Expand Down

0 comments on commit 4cb0a39

Please sign in to comment.