lib/install/webpack/install.rb in jsbundling-rails-1.0.3 vs lib/install/webpack/install.rb in jsbundling-rails-1.1.0
- old
+ new
@@ -3,11 +3,15 @@
run "yarn add webpack webpack-cli"
say "Add build script"
build_script = "webpack --config webpack.config.js"
-if (`npx -v`.to_f < 7.1 rescue "Missing")
- say %(Add "scripts": { "build": "#{build_script}" } to your package.json), :green
-else
+case `npx -v`.to_f
+when 7.1...8.0
run %(npm set-script build "#{build_script}")
run %(yarn build)
+when 8.0..
+ run %(npm pkg set scripts.build="#{build_script}")
+ run %(yarn build)
+else
+ say %(Add "scripts": { "build": "#{build_script}" } to your package.json), :green
end