Skip to content
This repository was archived by the owner on Oct 2, 2019. It is now read-only.

Commit e5f196b

Browse files
committed
Bring webpack tasks to npm scripts and wrap it with rakes
1 parent bfdac11 commit e5f196b

File tree

3 files changed

+10
-15
lines changed

3 files changed

+10
-15
lines changed

example/Procfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
# Run Rails & Webpack concurrently
22
# Example file from webpack-rails gem
33
rails: bundle exec rails server
4-
webpack: ./node_modules/.bin/webpack-dev-server --config config/webpack.config.js
4+
webpack: npm start

example/package.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22
"name": "webpack-rails-example",
33
"version": "0.0.1",
44
"license": "MIT",
5+
"scripts": {
6+
"compile": "webpack -d --config config/webpack.config.js",
7+
"serve": "webpack-dev-server -p --config config/webpack.config.js"
8+
},
59
"dependencies": {
610
"stats-webpack-plugin": "^0.2.1",
711
"webpack": "^1.9.11",

lib/tasks/webpack.rake

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,10 @@
11
namespace :webpack do
22
desc "Compile webpack bundles"
3-
task compile: :environment do
4-
ENV["TARGET"] = 'production' # TODO: Deprecated, use NODE_ENV instead
3+
task(:compile) do
54
ENV["NODE_ENV"] = 'production'
6-
webpack_bin = ::Rails.root.join(::Rails.configuration.webpack.binary)
7-
config_file = ::Rails.root.join(::Rails.configuration.webpack.config_file)
8-
9-
unless File.exist?(webpack_bin)
10-
raise "Can't find our webpack executable at #{webpack_bin} - have you run `npm install`?"
11-
end
12-
13-
unless File.exist?(config_file)
14-
raise "Can't find our webpack config file at #{config_file}"
15-
end
16-
17-
sh "#{webpack_bin} --config #{config_file} --bail"
5+
sh "npm run compile"
186
end
7+
8+
desc "Start webpack dev server"
9+
task(:serve) { sh "npm serve" }
1910
end

0 commit comments

Comments
 (0)