This repository has been archived by the owner on Oct 2, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 81
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Bring webpack tasks to npm scripts and wrap it with rakes
- Loading branch information
Showing
3 changed files
with
8 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
# Run Rails & Webpack concurrently | ||
# Example file from webpack-rails gem | ||
rails: bundle exec rails server | ||
webpack: ./node_modules/.bin/webpack-dev-server --config config/webpack.config.js | ||
webpack: npm start |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,7 @@ | ||
namespace :webpack do | ||
desc "Compile webpack bundles" | ||
task compile: :environment do | ||
ENV["TARGET"] = 'production' # TODO: Deprecated, use NODE_ENV instead | ||
ENV["NODE_ENV"] = 'production' | ||
webpack_bin = ::Rails.root.join(::Rails.configuration.webpack.binary) | ||
config_file = ::Rails.root.join(::Rails.configuration.webpack.config_file) | ||
task(:compile) { sh "npm run build" } | ||
|
||
unless File.exist?(webpack_bin) | ||
raise "Can't find our webpack executable at #{webpack_bin} - have you run `npm install`?" | ||
end | ||
|
||
unless File.exist?(config_file) | ||
raise "Can't find our webpack config file at #{config_file}" | ||
end | ||
|
||
sh "#{webpack_bin} --config #{config_file} --bail" | ||
end | ||
desc "Start webpack dev server" | ||
task(:dev) { sh "npm start" } | ||
end |