Skip to content

Commit

Permalink
Add custom_compile setting for webpacker.yml
Browse files Browse the repository at this point in the history
The custom compile setting is necessary to prevent the default
pre-compile task from running.
  • Loading branch information
justin808 committed Aug 17, 2017
1 parent 3f4ab24 commit 42549b0
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 35 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,10 @@ gem "webpacker", git: "https://github.com/shakacode/webpacker.git",


- Find your `webpacker_lite.yml` and rename it to `webpacker.yml`
- Add a default setting
```
custom_compile: true
```
- Add a section like this under your development env:
```
dev_server:
Expand Down Expand Up @@ -83,6 +87,8 @@ gem "webpacker", git: "https://github.com/shakacode/webpacker.git",
*Diffs for the beta to master*

### [9.0.0-beta.9]
- Fixes precompile task going to Webpacker's. You need to set `custom_compile: true` in your `webpacker.yml`.
- Changed webpack-bundle.js name to hello-world-bundle.js
- Update for latest from rails/webpacker
gem "webpacker", git: "https://github.com/shakacode/webpacker.git",
branch: "issue-464-merge-webpacker-lite-into-webpacker-v3"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
default: &default
# Critical to set compile as false for React on Rails projects
compile: false
custom_compile: true

development:
<<: *default
Expand All @@ -21,5 +22,5 @@ test:

production:
<<: *default
# generated files for tests, in /public/webpack/production
# generated files for production, in /public/webpack/production
public_output_path: webpack/production
4 changes: 2 additions & 2 deletions spec/dummy/Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
GIT
remote: https://github.com/shakacode/webpacker.git
revision: dfff9def3f0fb8bb3cd4b400b76ea1b2484fd6ce
revision: 89a59a3ceb7d6e5c9eaab01b841efa568564d21d
branch: issue-464-merge-webpacker-lite-into-webpacker-v3
specs:
webpacker (2.0)
Expand Down Expand Up @@ -175,7 +175,7 @@ GEM
public_suffix (2.0.5)
puma (3.9.1)
rack (2.0.3)
rack-proxy (0.6.1)
rack-proxy (0.6.2)
rack
rack-test (0.6.3)
rack (>= 1.0)
Expand Down
5 changes: 3 additions & 2 deletions spec/dummy/client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,9 @@
"build:test:server": "NODE_ENV=test webpack --config webpack.server.rails.build.config.js",
"build:dev:client": "NODE_ENV=development webpack -w --config webpack.client.rails.build.config.js",
"build:dev:server": "NODE_ENV=development webpack -w --config webpack.server.rails.build.config.js",
"build:production:client": "NODE_ENV=production webpack --config webpack.client.rails.build.config.js",
"build:production:server": "NODE_ENV=production webpack --config webpack.server.rails.build.config.js",
"build:production:client": "NODE_ENV=production webpack -p --config webpack.client.rails.build.config.js",
"build:production:server": "NODE_ENV=production webpack -p --config webpack.server.rails.build.config.js",
"build:production": "yarn run build:production:server && yarn run build:production:client",
"hot-assets": "NODE_ENV=development babel-node server-rails-hot.js"
},
"author": "",
Expand Down
5 changes: 3 additions & 2 deletions spec/dummy/config/webpacker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
default: &default
# Critical to set compile as false for React on Rails projects
compile: false
custom_compile: true

development:
<<: *default
Expand All @@ -16,10 +17,10 @@ development:

test:
<<: *default
# generated files for tests, in /public/webpack/test
# generated files for test, in /public/webpack/test
public_output_path: webpack/test

production:
<<: *default
# generated files for tests, in /public/webpack/production
# generated files for production, in /public/webpack/production
public_output_path: webpack/production
29 changes: 3 additions & 26 deletions spec/dummy/lib/tasks/assets.rake
Original file line number Diff line number Diff line change
@@ -1,28 +1,5 @@
# frozen_string_literal: true
# This file is no longer used, as the default precompile task works.

# lib/tasks/assets.rake
# The webpack task must run before assets:environment task.
# Otherwise Sprockets cannot find the files that webpack produces.
# This is the secret sauce for how a Heroku deployment knows to create the webpack generated JavaScript files.
Rake::Task["assets:precompile"]
.clear_prerequisites
.enhance(["assets:compile_environment"])

namespace :assets do
# In this task, set prerequisites for the assets:precompile task
task compile_environment: :webpack do
Rake::Task["assets:environment"].invoke
end

desc "Compile assets with webpack"
task :webpack do
sh "cd client && yarn run build:client"

# Skip next line if not doing server rendering
sh "cd client && yarn run build:server"
end

task :clobber do
rm_r Dir.glob(Rails.root.join("app/assets/webpack/*"))
end
end
# Create a file, per `docs/additional-reading/heroku-deployment.md` if you wish to customize
# the deployment precompile task.
4 changes: 2 additions & 2 deletions spec/react_on_rails/generators/install_generator_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@
- Include your webpack assets to your application layout. Change hello-world-bundle as needed.
<%= javascript_pack_tag 'hello-world-bundle' %>
<%= javascript_pack_tag 'hello-world-bundle' %>
- Ensure your bundle and yarn installs of dependencies are up to date.
Expand Down Expand Up @@ -109,7 +109,7 @@
- Include your webpack assets to your application layout. Change hello-world-bundle as needed.
<%= javascript_pack_tag 'hello-world-bundle' %>
<%= javascript_pack_tag 'hello-world-bundle' %>
- Ensure your bundle and yarn installs of dependencies are up to date.
Expand Down

0 comments on commit 42549b0

Please sign in to comment.