diff --git a/lib/tasks/assets.rake b/lib/tasks/assets.rake index 8b2f2b1..dd52bb6 100644 --- a/lib/tasks/assets.rake +++ b/lib/tasks/assets.rake @@ -7,8 +7,15 @@ desc "Pre-compile assets for production. Overwrite the Rails assets:precompile" task :precompile do FileUtils.cd("lib/assets") do + webpack_options = [] + # Don't watch asset files for further changes + webpack_options << "--no-watch" + # Add the production flag, if env is production + webpack_options << "-p" if ENV["RAILS_ENV"] == "production" + # Ensure all dependencies are installed system("npm install") - system("npm run bundle -- --no-watch -p") + # Run the webpack command via npm + system("npm run bundle -- #{webpack_options.join(" ")}") end end end