From e6edd4fb27ef84caf8ee6af6a3c2fbeeba2f9248 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sergio=20Rodr=C3=ADguez?= Date: Mon, 17 Jul 2017 17:20:11 +1000 Subject: [PATCH] Generated client/package.json creates production builds using webpack by default (#895) Adds `-p` option to generated files. --- CHANGELOG.md | 4 ++++ .../templates/base/base/client/package.json.tt | 2 +- .../support/shared_examples/base_generator_examples.rb | 7 +++++++ 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c997e341c..af94cf567 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,10 @@ All notable changes to this project's source code will be documented in this fil Contributors: please follow the recommendations outlined at [keepachangelog.com](http://keepachangelog.com/). Please use the existing headings and styling as a guide, and add a link for the version diff at the bottom of the file. Also, please update the `Unreleased` link to compare to the latest release version. ## [Unreleased] +### [8.0.6] +#### fixed +- The package.json file created by the generator now creates minified javascript production builds by default. This was done by adding the -p flag to webpack on the build:production script. + Changes since last non-beta release. *Please add entries here for your pull requests.* diff --git a/lib/generators/react_on_rails/templates/base/base/client/package.json.tt b/lib/generators/react_on_rails/templates/base/base/client/package.json.tt index c7d3f636c..646cb42f7 100644 --- a/lib/generators/react_on_rails/templates/base/base/client/package.json.tt +++ b/lib/generators/react_on_rails/templates/base/base/client/package.json.tt @@ -4,7 +4,7 @@ "private": true, "scripts": { "build:test": "NODE_ENV=test webpack --config webpack.config.js", - "build:production": "NODE_ENV=production webpack --config webpack.config.js", + "build:production": "NODE_ENV=production webpack -p --config webpack.config.js", "build:development": "NODE_ENV=development webpack -w --config webpack.config.js" }, "cacheDirectories": ["node_modules", "client/node_modules"], diff --git a/spec/react_on_rails/support/shared_examples/base_generator_examples.rb b/spec/react_on_rails/support/shared_examples/base_generator_examples.rb index 082fc72cf..8f04e5e0f 100644 --- a/spec/react_on_rails/support/shared_examples/base_generator_examples.rb +++ b/spec/react_on_rails/support/shared_examples/base_generator_examples.rb @@ -46,4 +46,11 @@ assert_match("registration", contents) end end + + it "creates a client/package.json file configured to create production builds" do + production_script = "NODE_ENV=production webpack -p --config webpack.config.js" + assert_file("client/package.json") do |contents| + assert_match(production_script, contents) + end + end end