Skip to content

Commit 42549b0

Browse files
committed
Add custom_compile setting for webpacker.yml
The custom compile setting is necessary to prevent the default pre-compile task from running.
1 parent 3f4ab24 commit 42549b0

File tree

7 files changed

+21
-35
lines changed

7 files changed

+21
-35
lines changed

CHANGELOG.md

+6
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,10 @@ gem "webpacker", git: "https://github.com/shakacode/webpacker.git",
5454
5555
5656
- Find your `webpacker_lite.yml` and rename it to `webpacker.yml`
57+
- Add a default setting
58+
```
59+
custom_compile: true
60+
```
5761
- Add a section like this under your development env:
5862
```
5963
dev_server:
@@ -83,6 +87,8 @@ gem "webpacker", git: "https://github.com/shakacode/webpacker.git",
8387
*Diffs for the beta to master*
8488
8589
### [9.0.0-beta.9]
90+
- Fixes precompile task going to Webpacker's. You need to set `custom_compile: true` in your `webpacker.yml`.
91+
- Changed webpack-bundle.js name to hello-world-bundle.js
8692
- Update for latest from rails/webpacker
8793
gem "webpacker", git: "https://github.com/shakacode/webpacker.git",
8894
branch: "issue-464-merge-webpacker-lite-into-webpacker-v3"

lib/generators/react_on_rails/templates/base/base/config/webpacker.yml

+2-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
default: &default
33
# Critical to set compile as false for React on Rails projects
44
compile: false
5+
custom_compile: true
56

67
development:
78
<<: *default
@@ -21,5 +22,5 @@ test:
2122

2223
production:
2324
<<: *default
24-
# generated files for tests, in /public/webpack/production
25+
# generated files for production, in /public/webpack/production
2526
public_output_path: webpack/production

spec/dummy/Gemfile.lock

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
GIT
22
remote: https://github.com/shakacode/webpacker.git
3-
revision: dfff9def3f0fb8bb3cd4b400b76ea1b2484fd6ce
3+
revision: 89a59a3ceb7d6e5c9eaab01b841efa568564d21d
44
branch: issue-464-merge-webpacker-lite-into-webpacker-v3
55
specs:
66
webpacker (2.0)
@@ -175,7 +175,7 @@ GEM
175175
public_suffix (2.0.5)
176176
puma (3.9.1)
177177
rack (2.0.3)
178-
rack-proxy (0.6.1)
178+
rack-proxy (0.6.2)
179179
rack
180180
rack-test (0.6.3)
181181
rack (>= 1.0)

spec/dummy/client/package.json

+3-2
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,9 @@
7575
"build:test:server": "NODE_ENV=test webpack --config webpack.server.rails.build.config.js",
7676
"build:dev:client": "NODE_ENV=development webpack -w --config webpack.client.rails.build.config.js",
7777
"build:dev:server": "NODE_ENV=development webpack -w --config webpack.server.rails.build.config.js",
78-
"build:production:client": "NODE_ENV=production webpack --config webpack.client.rails.build.config.js",
79-
"build:production:server": "NODE_ENV=production webpack --config webpack.server.rails.build.config.js",
78+
"build:production:client": "NODE_ENV=production webpack -p --config webpack.client.rails.build.config.js",
79+
"build:production:server": "NODE_ENV=production webpack -p --config webpack.server.rails.build.config.js",
80+
"build:production": "yarn run build:production:server && yarn run build:production:client",
8081
"hot-assets": "NODE_ENV=development babel-node server-rails-hot.js"
8182
},
8283
"author": "",

spec/dummy/config/webpacker.yml

+3-2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
default: &default
33
# Critical to set compile as false for React on Rails projects
44
compile: false
5+
custom_compile: true
56

67
development:
78
<<: *default
@@ -16,10 +17,10 @@ development:
1617

1718
test:
1819
<<: *default
19-
# generated files for tests, in /public/webpack/test
20+
# generated files for test, in /public/webpack/test
2021
public_output_path: webpack/test
2122

2223
production:
2324
<<: *default
24-
# generated files for tests, in /public/webpack/production
25+
# generated files for production, in /public/webpack/production
2526
public_output_path: webpack/production

spec/dummy/lib/tasks/assets.rake

+3-26
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,5 @@
11
# frozen_string_literal: true
2+
# This file is no longer used, as the default precompile task works.
23

3-
# lib/tasks/assets.rake
4-
# The webpack task must run before assets:environment task.
5-
# Otherwise Sprockets cannot find the files that webpack produces.
6-
# This is the secret sauce for how a Heroku deployment knows to create the webpack generated JavaScript files.
7-
Rake::Task["assets:precompile"]
8-
.clear_prerequisites
9-
.enhance(["assets:compile_environment"])
10-
11-
namespace :assets do
12-
# In this task, set prerequisites for the assets:precompile task
13-
task compile_environment: :webpack do
14-
Rake::Task["assets:environment"].invoke
15-
end
16-
17-
desc "Compile assets with webpack"
18-
task :webpack do
19-
sh "cd client && yarn run build:client"
20-
21-
# Skip next line if not doing server rendering
22-
sh "cd client && yarn run build:server"
23-
end
24-
25-
task :clobber do
26-
rm_r Dir.glob(Rails.root.join("app/assets/webpack/*"))
27-
end
28-
end
4+
# Create a file, per `docs/additional-reading/heroku-deployment.md` if you wish to customize
5+
# the deployment precompile task.

spec/react_on_rails/generators/install_generator_spec.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@
8181
8282
- Include your webpack assets to your application layout. Change hello-world-bundle as needed.
8383
84-
<%= javascript_pack_tag 'hello-world-bundle' %>
84+
<%= javascript_pack_tag 'hello-world-bundle' %>
8585
8686
- Ensure your bundle and yarn installs of dependencies are up to date.
8787
@@ -109,7 +109,7 @@
109109
110110
- Include your webpack assets to your application layout. Change hello-world-bundle as needed.
111111
112-
<%= javascript_pack_tag 'hello-world-bundle' %>
112+
<%= javascript_pack_tag 'hello-world-bundle' %>
113113
114114
- Ensure your bundle and yarn installs of dependencies are up to date.
115115

0 commit comments

Comments
 (0)