shakapacker 6.6.0 → 7.0.0.rc.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/ruby-backward-compatibility.yml +43 -0
- data/CHANGELOG.md +50 -4
- data/CONTRIBUTING.md +4 -4
- data/Gemfile.development_dependencies +1 -1
- data/README.md +113 -88
- data/Rakefile +5 -0
- data/config/shakapacker.yml +1 -0
- data/docs/deployment.md +12 -10
- data/docs/developing_webpacker.md +5 -5
- data/docs/react.md +10 -6
- data/docs/style_loader_vs_mini_css.md +2 -2
- data/docs/troubleshooting.md +22 -18
- data/docs/using_esbuild_loader.md +5 -3
- data/docs/using_swc_loader.md +2 -2
- data/docs/v6_upgrade.md +2 -2
- data/docs/v7_upgrade.md +56 -0
- data/lib/install/bin/shakapacker +13 -0
- data/lib/install/bin/shakapacker-dev-server +13 -0
- data/lib/install/config/{webpacker.yml → shakapacker.yml} +13 -8
- data/lib/install/template.rb +7 -7
- data/lib/{webpacker → shakapacker}/base_strategy.rb +2 -2
- data/lib/{webpacker → shakapacker}/commands.rb +4 -4
- data/lib/{webpacker → shakapacker}/compiler.rb +43 -15
- data/lib/{webpacker → shakapacker}/compiler_strategy.rb +6 -6
- data/lib/{webpacker → shakapacker}/configuration.rb +52 -21
- data/lib/shakapacker/deprecation_helper.rb +88 -0
- data/lib/{webpacker → shakapacker}/dev_server.rb +27 -4
- data/lib/{webpacker → shakapacker}/dev_server_proxy.rb +4 -4
- data/lib/shakapacker/dev_server_runner.rb +104 -0
- data/lib/{webpacker → shakapacker}/digest_strategy.rb +6 -6
- data/lib/{webpacker → shakapacker}/env.rb +8 -8
- data/lib/{webpacker → shakapacker}/helper.rb +20 -20
- data/lib/{webpacker → shakapacker}/instance.rb +13 -10
- data/lib/{webpacker → shakapacker}/manifest.rb +14 -14
- data/lib/{webpacker → shakapacker}/mtime_strategy.rb +5 -5
- data/lib/shakapacker/railtie.rb +70 -0
- data/lib/shakapacker/runner.rb +28 -0
- data/lib/shakapacker/utils/version_syntax_converter.rb +2 -2
- data/lib/{webpacker → shakapacker}/version.rb +2 -2
- data/lib/{webpacker → shakapacker}/version_checker.rb +8 -8
- data/lib/shakapacker/webpack_runner.rb +67 -0
- data/lib/shakapacker.rb +51 -1
- data/lib/tasks/shakapacker/binstubs.rake +15 -0
- data/lib/tasks/shakapacker/check_binstubs.rake +25 -0
- data/lib/tasks/shakapacker/check_node.rake +31 -0
- data/lib/tasks/shakapacker/check_yarn.rake +33 -0
- data/lib/tasks/shakapacker/clean.rake +23 -0
- data/lib/tasks/shakapacker/clobber.rake +18 -0
- data/lib/tasks/shakapacker/compile.rake +31 -0
- data/lib/tasks/shakapacker/info.rake +21 -0
- data/lib/tasks/shakapacker/install.rake +17 -0
- data/lib/tasks/shakapacker/verify_config.rake +12 -0
- data/lib/tasks/shakapacker/verify_install.rake +4 -0
- data/lib/tasks/shakapacker/yarn_install.rake +24 -0
- data/lib/tasks/shakapacker.rake +18 -0
- data/lib/tasks/webpacker/binstubs.rake +5 -11
- data/lib/tasks/webpacker/check_binstubs.rake +6 -9
- data/lib/tasks/webpacker/check_node.rake +5 -27
- data/lib/tasks/webpacker/check_yarn.rake +5 -29
- data/lib/tasks/webpacker/clean.rake +5 -19
- data/lib/tasks/webpacker/clobber.rake +6 -13
- data/lib/tasks/webpacker/compile.rake +5 -33
- data/lib/tasks/webpacker/info.rake +5 -17
- data/lib/tasks/webpacker/install.rake +5 -13
- data/lib/tasks/webpacker/verify_config.rake +6 -11
- data/lib/tasks/webpacker/verify_install.rake +7 -2
- data/lib/tasks/webpacker/yarn_install.rake +5 -20
- data/lib/tasks/webpacker.rake +15 -13
- data/lib/webpacker/dev_server_runner.rb +9 -96
- data/lib/webpacker/webpack_runner.rb +9 -58
- data/lib/webpacker.rb +3 -47
- data/package/__tests__/config-bc.js +27 -0
- data/package/__tests__/config.js +6 -5
- data/package/__tests__/dev_server-bc.js +46 -0
- data/package/__tests__/dev_server.js +9 -8
- data/package/__tests__/development-bc.js +66 -0
- data/package/__tests__/development.js +36 -5
- data/package/__tests__/env-bc.js +59 -0
- data/package/__tests__/env.js +3 -2
- data/package/__tests__/index.js +13 -0
- data/package/__tests__/production-bc.js +51 -0
- data/package/__tests__/production.js +25 -3
- data/package/__tests__/staging-bc.js +53 -0
- data/package/__tests__/staging.js +27 -4
- data/package/__tests__/test-bc.js +43 -0
- data/package/__tests__/test.js +22 -4
- data/package/babel/preset.js +1 -4
- data/package/config.js +25 -7
- data/package/dev_server.js +7 -4
- data/package/env.js +22 -3
- data/package/environments/__tests__/base-bc.js +107 -0
- data/package/environments/__tests__/base.js +13 -13
- data/package/environments/base.js +1 -1
- data/package/environments/development.js +4 -46
- data/package/environments/production.js +1 -1
- data/package/index.js +11 -4
- data/package/rules/__tests__/__utils__/webpack.js +1 -1
- data/package/rules/__tests__/file.js +27 -0
- data/package/rules/__tests__/swc.js +1 -2
- data/package/rules/file.js +2 -2
- data/package/utils/configPath.js +19 -0
- data/package/utils/defaultConfigPath.js +2 -0
- data/package/utils/get_style_rule.js +5 -2
- data/package/utils/helpers.js +24 -1
- data/package/utils/inliningCss.js +7 -0
- data/package/utils/snakeToCamelCase +7 -0
- data/package/webpackDevServerConfig.js +68 -0
- data/package.json +2 -2
- data/{webpacker.gemspec → shakapacker.gemspec} +3 -3
- data/spec/backward_compatibility_specs/command_spec_bc.rb +116 -0
- data/spec/backward_compatibility_specs/compiler_spec_bc.rb +59 -0
- data/spec/backward_compatibility_specs/compiler_strategy_spec_bc.rb +22 -0
- data/spec/backward_compatibility_specs/configuration_spec_bc.rb +286 -0
- data/spec/backward_compatibility_specs/dev_server_runner_spec_bc.rb +79 -0
- data/spec/backward_compatibility_specs/dev_server_spec_bc.rb +47 -0
- data/spec/backward_compatibility_specs/digest_strategy_spec_bc.rb +35 -0
- data/spec/backward_compatibility_specs/engine_rake_tasks_spec_bc.rb +44 -0
- data/spec/backward_compatibility_specs/env_spec_bc.rb +23 -0
- data/spec/backward_compatibility_specs/helper_spec_bc.rb +243 -0
- data/spec/backward_compatibility_specs/instance_spec_bc.rb +31 -0
- data/spec/backward_compatibility_specs/manifest_spec_bc.rb +100 -0
- data/spec/backward_compatibility_specs/mtime_strategy_spec_bc.rb +55 -0
- data/spec/backward_compatibility_specs/rake_tasks_spec_bc.rb +37 -0
- data/spec/backward_compatibility_specs/spec_helper_initializer.rb +24 -0
- data/spec/backward_compatibility_specs/webpack_runner_spec_bc.rb +56 -0
- data/spec/backward_compatibility_specs/webpacker_spec_bc.rb +41 -0
- data/spec/backward_compatibility_specs/webpacker_test_app/.gitignore +2 -0
- data/spec/backward_compatibility_specs/webpacker_test_app/Rakefile +3 -0
- data/spec/{test_app → backward_compatibility_specs/webpacker_test_app}/app/packs/entrypoints/application.js +1 -1
- data/{lib/install → spec/backward_compatibility_specs/webpacker_test_app}/bin/webpacker +0 -0
- data/spec/backward_compatibility_specs/webpacker_test_app/config/application.rb +11 -0
- data/spec/backward_compatibility_specs/webpacker_test_app/config/environment.rb +4 -0
- data/spec/backward_compatibility_specs/webpacker_test_app/config/initializers/inspect_autoload_paths.rb +1 -0
- data/spec/backward_compatibility_specs/webpacker_test_app/config/webpack/webpack.config.js +0 -0
- data/spec/{test_app → backward_compatibility_specs/webpacker_test_app}/config/webpacker.yml +1 -1
- data/spec/{test_app → backward_compatibility_specs/webpacker_test_app}/config/webpacker_css_extract_ignore_order_warnings.yml +1 -1
- data/spec/{test_app → backward_compatibility_specs/webpacker_test_app}/config/webpacker_defaults_fallback.yml +1 -1
- data/spec/backward_compatibility_specs/webpacker_test_app/config/webpacker_no_precompile.yml +7 -0
- data/spec/{test_app → backward_compatibility_specs/webpacker_test_app}/config/webpacker_other_location.yml +1 -1
- data/spec/{test_app → backward_compatibility_specs/webpacker_test_app}/config/webpacker_public_root.yml +1 -1
- data/spec/backward_compatibility_specs/webpacker_test_app/config.ru +5 -0
- data/spec/backward_compatibility_specs/webpacker_test_app/package.json +13 -0
- data/spec/backward_compatibility_specs/webpacker_test_app/public/packs/manifest.json +58 -0
- data/spec/backward_compatibility_specs/webpacker_test_app/some.config.js +0 -0
- data/spec/backward_compatibility_specs/webpacker_test_app/tmp/shakapacker/last-compilation-digest-production +1 -0
- data/spec/backward_compatibility_specs/webpacker_test_app/yarn.lock +11 -0
- data/spec/command_spec.rb +18 -16
- data/spec/compiler_spec.rb +19 -17
- data/spec/compiler_strategy_spec.rb +9 -7
- data/spec/configuration_spec.rb +108 -66
- data/spec/dev_server_runner_spec.rb +9 -8
- data/spec/dev_server_spec.rb +97 -9
- data/spec/digest_strategy_spec.rb +4 -2
- data/spec/engine_rake_tasks_spec.rb +12 -16
- data/spec/env_spec.rb +7 -5
- data/spec/helper_spec.rb +4 -2
- data/spec/instance_spec.rb +31 -0
- data/spec/manifest_spec.rb +21 -19
- data/spec/mounted_app/test/dummy/config/application.rb +1 -1
- data/spec/mounted_app/test/dummy/config/webpacker.yml +3 -3
- data/spec/mtime_strategy_spec.rb +4 -2
- data/spec/rake_tasks_spec.rb +20 -18
- data/spec/spec_helper.rb +0 -25
- data/spec/spec_helper_initializer.rb +24 -0
- data/spec/test_app/.gitignore +2 -0
- data/spec/test_app/app/javascript/entrypoints/application.js +10 -0
- data/spec/test_app/app/javascript/entrypoints/generated/something.js +2 -0
- data/spec/test_app/app/javascript/entrypoints/multi_entry.css +4 -0
- data/spec/test_app/app/javascript/entrypoints/multi_entry.js +4 -0
- data/spec/test_app/bin/{webpacker-dev-server → shakapacker} +3 -3
- data/spec/test_app/bin/{webpacker → shakapacker-dev-server} +3 -3
- data/spec/test_app/config/application.rb +1 -1
- data/spec/test_app/config/shakapacker.yml +82 -0
- data/spec/test_app/config/shakapacker_css_extract_ignore_order_warnings.yml +84 -0
- data/spec/test_app/config/shakapacker_defaults_fallback.yml +11 -0
- data/spec/test_app/config/shakapacker_manifest_path.yml +80 -0
- data/spec/test_app/config/shakapacker_nested_entries.yml +83 -0
- data/spec/test_app/config/shakapacker_no_precompile.yml +7 -0
- data/spec/test_app/config/shakapacker_other_location.yml +85 -0
- data/spec/test_app/config/shakapacker_public_root.yml +18 -0
- data/spec/version_checker_spec.rb +16 -15
- data/spec/webpack_runner_spec.rb +4 -3
- data/spec/webpacker_spec.rb +9 -29
- metadata +119 -44
- data/config/webpacker.yml +0 -1
- data/lib/webpacker/railtie.rb +0 -70
- data/lib/webpacker/runner.rb +0 -23
- data/package/configPath.js +0 -3
- data/package/inliningCss.js +0 -7
- data/spec/test_app/config/webpacker_no_precompile.yml +0 -7
- /data/spec/{test_app → backward_compatibility_specs/webpacker_test_app}/app/packs/entrypoints/generated/something.js +0 -0
- /data/spec/{test_app → backward_compatibility_specs/webpacker_test_app}/app/packs/entrypoints/multi_entry.css +0 -0
- /data/spec/{test_app → backward_compatibility_specs/webpacker_test_app}/app/packs/entrypoints/multi_entry.js +0 -0
- /data/{lib/install → spec/backward_compatibility_specs/webpacker_test_app}/bin/webpacker-dev-server +0 -0
- /data/spec/{test_app → backward_compatibility_specs/webpacker_test_app}/config/webpacker_manifest_path.yml +0 -0
- /data/spec/{test_app → backward_compatibility_specs/webpacker_test_app}/config/webpacker_nested_entries.yml +0 -0
@@ -1,4 +1,4 @@
|
|
1
|
-
# Developing
|
1
|
+
# Developing Shakapacker
|
2
2
|
|
3
3
|
It's a little trickier for Rails developers to work on the JS code of a project like shakacode/shakapacker. So here are some tips!
|
4
4
|
|
@@ -7,16 +7,16 @@ For example, for React on Rails Changes, I'm using [shakacode/react_on_rails_tut
|
|
7
7
|
This directory is the `TEST_APP_DIR`.
|
8
8
|
|
9
9
|
## Fork shakacode/shakapacker
|
10
|
-
Let's call the shakacode/shakapacker directory `
|
10
|
+
Let's call the shakacode/shakapacker directory `SHAKAPACKER_DIR` which has shakacode/shakapacker's `package.json`.
|
11
11
|
|
12
12
|
## Changing the Package
|
13
13
|
### Setup with Yalc
|
14
14
|
Use [`yalc`](https://github.com/wclr/yalc) unless you like yak shaving weird errors.
|
15
|
-
1. In `
|
15
|
+
1. In `SHAKAPACKER_DIR`, run `yalc publish`
|
16
16
|
2. In `TEST_APP_DIR`, run `yalc link shakapacker`
|
17
17
|
|
18
18
|
## Update the Package Code
|
19
|
-
1. Make some JS change in
|
19
|
+
1. Make some JS change in SHAKAPACKER_DIR
|
20
20
|
2. Run `yalc push` and your changes will be pushed to your `TEST_APP_DIR`'s node_modules.
|
21
21
|
3. You may need to run `yarn` in `TEST_APP_DIR` if you added or removed dependencies of shakacode/shakapacker.
|
22
22
|
|
@@ -25,5 +25,5 @@ Use [`yalc`](https://github.com/wclr/yalc) unless you like yak shaving weird err
|
|
25
25
|
For the Ruby part, just change the gem reference `TEST_APP_DIR`, like:
|
26
26
|
|
27
27
|
```ruby
|
28
|
-
gem "
|
28
|
+
gem "shakapacker", path: "../../forks/shakapacker"
|
29
29
|
```
|
data/docs/react.md
CHANGED
@@ -47,7 +47,7 @@ With HMR enabled, Shakapacker will automatically update only that part of the pa
|
|
47
47
|
|
48
48
|
To enable HMR in a React app, proceed as follows:.
|
49
49
|
|
50
|
-
In `config/
|
50
|
+
In `config/shakapacker.yml` set `hmr` is set to `true`.
|
51
51
|
|
52
52
|
Install the [react-refresh](https://www.npmjs.com/package/react-refresh) package, as well as [@pmmmwh/react-refresh-webpack-plugin](https://www.npmjs.com/package/@pmmmwh/react-refresh-webpack-plugin):
|
53
53
|
|
@@ -58,10 +58,12 @@ yarn add --dev react-refresh @pmmmwh/react-refresh-webpack-plugin
|
|
58
58
|
Alter `config/webpack/webpack.config.js` like so:
|
59
59
|
|
60
60
|
```js
|
61
|
-
const {
|
61
|
+
const { generateWebpackConfig, inliningCss } = require('shakapacker');
|
62
62
|
const ReactRefreshWebpackPlugin = require('@pmmmwh/react-refresh-webpack-plugin');
|
63
63
|
const isDevelopment = process.env.NODE_ENV !== 'production';
|
64
64
|
|
65
|
+
const webpackConfig = generateWebpackConfig();
|
66
|
+
|
65
67
|
if (isDevelopment && inliningCss) {
|
66
68
|
webpackConfig.plugins.push(
|
67
69
|
new ReactRefreshWebpackPlugin({
|
@@ -139,7 +141,7 @@ rails new myapp --skip-javascript
|
|
139
141
|
cd myapp
|
140
142
|
bundle add shakapacker --strict
|
141
143
|
./bin/bundle install
|
142
|
-
./bin/rails
|
144
|
+
./bin/rails shakapacker:install
|
143
145
|
yarn add react react-dom @babel/preset-react
|
144
146
|
yarn add css-loader style-loader mini-css-extract-plugin css-minimizer-webpack-plugin
|
145
147
|
```
|
@@ -182,7 +184,7 @@ export default HelloMessage;
|
|
182
184
|
h1 { color: blue; }
|
183
185
|
```
|
184
186
|
|
185
|
-
7. Enable HMR in config/
|
187
|
+
7. Enable HMR in config/shakapacker.yml:
|
186
188
|
```shell
|
187
189
|
hmr: true
|
188
190
|
```
|
@@ -196,10 +198,12 @@ yarn add --dev react-refresh @pmmmwh/react-refresh-webpack-plugin
|
|
196
198
|
9. Alter `config/webpack/webpack.config.js` like so:
|
197
199
|
|
198
200
|
```js
|
199
|
-
const {
|
201
|
+
const { generateWebpackConfig, inliningCss } = require('shakapacker');
|
200
202
|
const ReactRefreshWebpackPlugin = require('@pmmmwh/react-refresh-webpack-plugin');
|
201
203
|
const isDevelopment = process.env.NODE_ENV !== 'production';
|
202
204
|
|
205
|
+
const webpackConfig = generateWebpackConfig();
|
206
|
+
|
203
207
|
if (isDevelopment && inliningCss) {
|
204
208
|
webpackConfig.plugins.push(
|
205
209
|
new ReactRefreshWebpackPlugin({
|
@@ -261,7 +265,7 @@ module.exports = function (api) {
|
|
261
265
|
9. Start the Rails server and the webpack-dev-server in separate console windows:
|
262
266
|
```shell
|
263
267
|
rails s
|
264
|
-
./bin/
|
268
|
+
./bin/shakapacker-dev-server
|
265
269
|
```
|
266
270
|
|
267
271
|
10. Hit: <http://localhost:3000/site/index>
|
@@ -2,10 +2,10 @@
|
|
2
2
|
|
3
3
|
You have two options for serving CSS in development:
|
4
4
|
|
5
|
-
1. You can opt to serve CSS via style-loader (as was traditionally done in a Webpack setup), where CSS is written by Javascript served by
|
5
|
+
1. You can opt to serve CSS via style-loader (as was traditionally done in a Webpack setup), where CSS is written by Javascript served by Shakapacker into a `<style>` tag, or
|
6
6
|
2. You can opt to serve CSS as a full CSS file via mini-css-extract-plugin, which uses a standard `<link>` tag to load a fully separate CSS file.
|
7
7
|
|
8
|
-
Both options support HMR. The default is style-loader. If you want to use mini-css-extract-plugin in development, set `inline_css: false` in the development dev_server section of your
|
8
|
+
Both options support HMR. The default is style-loader. If you want to use mini-css-extract-plugin in development, set `inline_css: false` in the development dev_server section of your shakapacker.yml:
|
9
9
|
|
10
10
|
```yml
|
11
11
|
development:
|
data/docs/troubleshooting.md
CHANGED
@@ -5,7 +5,7 @@
|
|
5
5
|
1. Read the error message carefully. The error message will tell you the precise key value
|
6
6
|
that is not matching what Webpack expects.
|
7
7
|
|
8
|
-
2. Put a `debugger` statement in your Webpack configuration and run `bin/
|
8
|
+
2. Put a `debugger` statement in your Webpack configuration and run `bin/shakapacker --debug-shakapacker`.
|
9
9
|
If you have a node debugger installed, you'll see the Chrome debugger for your webpack
|
10
10
|
config. For example, install the Chrome extension
|
11
11
|
[NiM](https://chrome.google.com/webstore/detail/nodejs-v8-inspector-manag/gnhhdgbaldcilmgcpfddgdbkhjohddkj) and
|
@@ -13,9 +13,9 @@
|
|
13
13
|
For more details on debugging, see the official
|
14
14
|
[Webpack docs on debugging](https://webpack.js.org/contribute/debugging/#devtools)
|
15
15
|
|
16
|
-
3. Any arguments that you add to bin/
|
16
|
+
3. Any arguments that you add to bin/shakapacker get sent to webpack. For example, you can pass `--debug` to switch loaders to debug mode. See [webpack CLI debug options](https://webpack.js.org/api/cli/#debug-options) for more information on the available options.
|
17
17
|
|
18
|
-
4. You can also pass additional options to the command to run the webpack-dev-server and start the webpack-dev-server with the option `--debug-
|
18
|
+
4. You can also pass additional options to the command to run the webpack-dev-server and start the webpack-dev-server with the option `--debug-shakapacker`
|
19
19
|
|
20
20
|
## Incorrect peer dependencies
|
21
21
|
The latest version of Shakapacker uses peer dependencies to make upgrading easier. However, there's a catch.
|
@@ -38,12 +38,12 @@ So, be sure to investigate warnings from `yarn install`!
|
|
38
38
|
## ENOENT: no such file or directory - node-sass
|
39
39
|
|
40
40
|
If you get the error `ENOENT: no such file or directory - node-sass` on deploy with
|
41
|
-
`assets:precompile` or `bundle exec rails
|
41
|
+
`assets:precompile` or `bundle exec rails shakapacker:compile` you may need to
|
42
42
|
move Sass to production `dependencies`.
|
43
43
|
|
44
44
|
Move any packages that related to Sass (e.g. `node-sass` or `sass-loader`) from
|
45
45
|
`devDependencies` to `dependencies` in `package.json`. This is because
|
46
|
-
|
46
|
+
shakapacker is running on a production system with the Rails workflow to build
|
47
47
|
the assets. Particularly on hosting providers that try to detect and do the right
|
48
48
|
thing, like Heroku.
|
49
49
|
|
@@ -64,11 +64,11 @@ In `package.json`:
|
|
64
64
|
|
65
65
|
* If you get this error `Can't find hello_react.js in manifest.json`
|
66
66
|
when loading a view in the browser it's because webpack is still compiling packs.
|
67
|
-
|
67
|
+
Shakapacker uses a `manifest.json` file to keep track of packs in all environments,
|
68
68
|
however since this file is generated after packs are compiled by webpack. So,
|
69
69
|
if you load a view in browser whilst webpack is compiling you will get this error.
|
70
70
|
Therefore, make sure webpack
|
71
|
-
(i.e `./bin/
|
71
|
+
(i.e `./bin/shakapacker-dev-server`) is running and has
|
72
72
|
completed the compilation successfully before loading a view.
|
73
73
|
|
74
74
|
|
@@ -85,7 +85,7 @@ completed the compilation successfully before loading a view.
|
|
85
85
|
|
86
86
|
## webpack or webpack-dev-server not found
|
87
87
|
|
88
|
-
* This could happen if `
|
88
|
+
* This could happen if `shakapacker:install` step is skipped. Please run `bundle exec rails shakapacker:install` to fix the issue.
|
89
89
|
|
90
90
|
* If you encounter the above error on heroku after upgrading from Rails 4.x to 5.1.x, then the problem might be related to missing `yarn` binstub. Please run following commands to update/add binstubs:
|
91
91
|
|
@@ -97,7 +97,7 @@ bundle config --delete bin
|
|
97
97
|
## Running webpack on Windows
|
98
98
|
|
99
99
|
If you are running webpack on Windows, your command shell may not be able to interpret the preferred interpreter
|
100
|
-
for the scripts generated in `bin/
|
100
|
+
for the scripts generated in `bin/shakapacker` and `bin/shakapacker-dev-server`. Instead you'll want to run the scripts
|
101
101
|
manually with Ruby:
|
102
102
|
|
103
103
|
```
|
@@ -107,7 +107,7 @@ C:\path>ruby bin\webpack-dev-server
|
|
107
107
|
|
108
108
|
## Invalid configuration object. webpack has been initialised using a configuration object that does not match the API schema.
|
109
109
|
|
110
|
-
If you receive this error when running `$ ./bin/
|
110
|
+
If you receive this error when running `$ ./bin/shakapacker-dev-server` ensure your configuration is correct; most likely the path to your "packs" folder is incorrect if you modified from the original "source_path" defined in `config/shakapacker.yml`.
|
111
111
|
|
112
112
|
## Running Elm on Continuous Integration (CI) services such as CircleCI, CodeShip, Travis CI
|
113
113
|
|
@@ -132,7 +132,7 @@ chmod +x $HOME/your_rails_app/node_modules/.bin/elm-make
|
|
132
132
|
```
|
133
133
|
|
134
134
|
## Rake assets:precompile fails. ExecJS::RuntimeError
|
135
|
-
This error occurs because you are trying to minify by `terser` a pack that's already been minified by
|
135
|
+
This error occurs because you are trying to minify by `terser` a pack that's already been minified by Shakapacker. To avoid this conflict and prevent appearing of `ExecJS::RuntimeError` error, you will need to disable uglifier from Rails config:
|
136
136
|
|
137
137
|
```ruby
|
138
138
|
# In production.rb
|
@@ -150,7 +150,9 @@ To silent these warnings, please update `config/webpack/webpack.config.js`:
|
|
150
150
|
```js
|
151
151
|
const webpack = require('webpack')
|
152
152
|
const { resolve } = require('path')
|
153
|
-
const {
|
153
|
+
const { generateWebpackConfig, merge } = require('shakapacker')
|
154
|
+
|
155
|
+
const webpackConfig = generateWebpackConfig();
|
154
156
|
|
155
157
|
module.exports = merge(webpackConfig, {
|
156
158
|
plugins: [
|
@@ -164,10 +166,10 @@ module.exports = merge(webpackConfig, {
|
|
164
166
|
|
165
167
|
### Compilation Fails Silently
|
166
168
|
|
167
|
-
If compiling is not producing output files and there are no error messages to help troubleshoot. Setting the `webpack_compile_output` configuration variable to `true` in
|
169
|
+
If compiling is not producing output files and there are no error messages to help troubleshoot. Setting the `webpack_compile_output` configuration variable to `true` in shakapacker.yml may add some helpful error information to your log file (Rails `log/development.log` or `log/production.log`)
|
168
170
|
|
169
171
|
```yml
|
170
|
-
#
|
172
|
+
# shakapacker.yml
|
171
173
|
default: &default
|
172
174
|
source_path: app/javascript
|
173
175
|
source_entry_path: packs
|
@@ -188,7 +190,7 @@ Thus ProvidePlugin manages build-time dependencies to global symbols whereas the
|
|
188
190
|
|
189
191
|
For instance, with [jQuery](https://jquery.com/):
|
190
192
|
```diff
|
191
|
-
// app/
|
193
|
+
// app/javascript/entrypoints/application.js
|
192
194
|
|
193
195
|
- import jQuery from 'jquery'
|
194
196
|
- window.jQuery = jQuery
|
@@ -199,7 +201,9 @@ Instead do:
|
|
199
201
|
// config/webpack/webpack.config.js
|
200
202
|
|
201
203
|
const webpack = require('webpack')
|
202
|
-
const {
|
204
|
+
const { generateWebpackConfig, merge } = require('shakapacker')
|
205
|
+
|
206
|
+
const webpackConfig = generateWebpackConfig();
|
203
207
|
|
204
208
|
module.exports = merge(webpackConfig, {
|
205
209
|
plugins: [
|
@@ -218,11 +222,11 @@ using Heroku's Pipeline promote feature). You might find that your production
|
|
218
222
|
application is using your staging `config.asset_host` host when using
|
219
223
|
`javascript_pack_tag`.
|
220
224
|
|
221
|
-
This can be fixed by setting the environment variable `
|
225
|
+
This can be fixed by setting the environment variable `SHAKAPACKER_ASSET_HOST` to
|
222
226
|
an empty string where your assets are compiled. On Heroku this is done under
|
223
227
|
*Settings* -> *Config Vars*.
|
224
228
|
|
225
|
-
This way
|
229
|
+
This way shakapacker won't hard-code the CDN host into the manifest file used by
|
226
230
|
`javascript_pack_tag`, but instead fetch the CDN host at runtime, resolving the
|
227
231
|
issue.
|
228
232
|
|
@@ -27,7 +27,7 @@ To use esbuild as your transpiler today. You need to do two things:
|
|
27
27
|
yarn add esbuild esbuild-loader
|
28
28
|
```
|
29
29
|
|
30
|
-
2. Add or change `
|
30
|
+
2. Add or change `shakapacker_loader` value in your default `shakapacker.yml` config to `esbuild`
|
31
31
|
The default configuration of babel is done by using `package.json` to use the file within the `shakapacker` package.
|
32
32
|
|
33
33
|
```yml
|
@@ -36,7 +36,7 @@ default: &default
|
|
36
36
|
source_entry_path: /
|
37
37
|
public_root_path: public
|
38
38
|
public_output_path: packs
|
39
|
-
cache_path: tmp/
|
39
|
+
cache_path: tmp/shakapacker
|
40
40
|
webpack_compile_output: true
|
41
41
|
|
42
42
|
# Additional paths webpack should look up modules
|
@@ -59,9 +59,11 @@ o do so, you need to modify your webpack configuration and use `ESBuildMinifyPlu
|
|
59
59
|
Example:
|
60
60
|
|
61
61
|
```js
|
62
|
-
const {
|
62
|
+
const { generateWebpackConfig, merge } = require('shakapacker')
|
63
63
|
const { ESBuildMinifyPlugin } = require('esbuild-loader')
|
64
64
|
|
65
|
+
const baseWebpackConfig = generateWebpackConfig()
|
66
|
+
|
65
67
|
const options = {
|
66
68
|
optimization: {
|
67
69
|
minimizer: [
|
data/docs/using_swc_loader.md
CHANGED
@@ -22,7 +22,7 @@ In order to use SWC as your compiler today. You need to do two things:
|
|
22
22
|
yarn add @swc/core swc-loader
|
23
23
|
```
|
24
24
|
|
25
|
-
2. Add or change `webpack_loader` value in your default `
|
25
|
+
2. Add or change `webpack_loader` value in your default `shakapacker.yml` config to `swc`
|
26
26
|
The default configuration of babel is done by using `package.json` to use the file within the `shakapacker` package.
|
27
27
|
|
28
28
|
```yml
|
@@ -31,7 +31,7 @@ default: &default
|
|
31
31
|
source_entry_path: /
|
32
32
|
public_root_path: public
|
33
33
|
public_output_path: packs
|
34
|
-
cache_path: tmp/
|
34
|
+
cache_path: tmp/shakapacker
|
35
35
|
webpack_compile_output: true
|
36
36
|
|
37
37
|
# Additional paths webpack should look up modules
|
data/docs/v6_upgrade.md
CHANGED
@@ -25,8 +25,7 @@ _If you're on webpacker v5, follow [how to upgrade to webpacker v6.0.0.rc.6 from
|
|
25
25
|
1. Install the peer dependencies. Run `yarn add @babel/core @babel/plugin-transform-runtime @babel/preset-env @babel/runtime babel-loader compression-webpack-plugin terser-webpack-plugin webpack webpack-assets-manifest webpack-cli webpack-merge webpack-sources webpack-dev-server`. You may have old versions of libraries. Run `yarn install` and check for warnings like `warning " > shakapacker@6.1.1" has incorrect peer dependency "compression-webpack-plugin@^9.0.0"` and `file-loader@1.1.11" has incorrect peer dependency "webpack@^2.0.0 || ^3.0.0 || ^4.0.0"`. In other words, warnings like these are **serious** and will cause considerable confusion if not respected.
|
26
26
|
1. Update any scripts that called `bin/webpack` or `bin/webpack-dev-server` to `bin/webpacker` or `bin/webpacker-dev-server`
|
27
27
|
1. Update your webpack config for a single config file, `config/webpack/webpack.config.js`. If you want to use the prior style of having a separate file for each NODE_ENV, you can use this shim for `config/webpack/webpack.config.js`. WARNING, previously, if you did not set `NODE_ENV`, `NODE_ENV` defaulted to `development`. Thus, you might expect `config/webpack/development.js` to run, but you'll instead be using the the configuration file that corresponds to your `RAILS_ENV`. If your `RAILS_ENV` is `test`, you'd be running `config/webpack/test.js`.
|
28
|
-
|
29
|
-
```js
|
28
|
+
```js
|
30
29
|
// name this file config/webpack/webpack.config.js
|
31
30
|
const { env, webpackConfig } = require('shakapacker')
|
32
31
|
const { existsSync } = require('fs')
|
@@ -46,6 +45,7 @@ _If you're on webpacker v5, follow [how to upgrade to webpacker v6.0.0.rc.6 from
|
|
46
45
|
module.exports = envSpecificConfig()
|
47
46
|
```
|
48
47
|
1. Update `babel.config.js` if you need JSX support. See [Customizing Babel Config](./customizing_babel_config.md)
|
48
|
+
1. If you are using the view helper called `asset_pack_path`, change "media/" in path to "static/" or consider using the `image_pack_path`.
|
49
49
|
|
50
50
|
## How to upgrade to Webpacker v6.0.0.rc.6 from v5
|
51
51
|
1. Ensure you have a clean working git branch. You will be overwriting all your files and reverting the changes that you don't want.
|
data/docs/v7_upgrade.md
ADDED
@@ -0,0 +1,56 @@
|
|
1
|
+
# Upgrading from Shakapacker v6 to v7
|
2
|
+
|
3
|
+
There will be several substantial and breaking changes in Shakapacker v7 that you need to manually account for when coming from Shakapacker v6.
|
4
|
+
|
5
|
+
## Usages of 'webpacker' should now be 'shakapacker'
|
6
|
+
|
7
|
+
Shakapacker v6 kept the 'webpacker' spelling. As a result, many config filenames, environment variables, rake tasks, etc., used the 'webpacker' spelling. Shakapacker 7 requires renaming to the 'shakapacker' spelling.
|
8
|
+
|
9
|
+
Shakapacker v7 provides a high degree of backward compatibility for spelling changes. It displays deprecation messages in the terminal to help the developers have a smooth experience in making the required transition to the new requirements.
|
10
|
+
|
11
|
+
Please note that Shakapacker v8 will remove any backward compatibility for spelling.
|
12
|
+
|
13
|
+
### Upgrade Steps
|
14
|
+
|
15
|
+
**Note:** At each step of changing the version, ensure that you update both gem and npm versions to the same "exact" version (like `x.y.z` and not `^x.y.z` or `>= x.y.z`).
|
16
|
+
|
17
|
+
1. Upgrade Shakapacker to the latest 6.x version and ensure no issues running your application.
|
18
|
+
2. Upgrade Shakapacker to version 7.
|
19
|
+
3. Run `rake shakapacker:binstubs` to get the new files in place. Then delete the `bin/webpacker` and `bin/webpacker-dev-server` ones.
|
20
|
+
4. Change spelling from Webpacker to Shakapacker in the code
|
21
|
+
- Change `webpacker_precompile` entry to `shakapacker_precompile` if it exists in the config file.
|
22
|
+
- Rename Ruby constant `Webpacker` to `Shakapacker` doing a global search and replace in your code. You might not be using it.
|
23
|
+
- Rename`Shakapacker.config.webpacker_precompile?` method, replace it with `Shakapacker.config.shakapacker_precompile?`
|
24
|
+
- `--debug-webpacker` is now `--debug-shakapacker` for your shakapacker binstubs.
|
25
|
+
5. Rename files
|
26
|
+
- Rename `config/webpacker.yml` to `config/shakapacker.yml`.
|
27
|
+
- Rename environment variables from `WEBPACKER_XYZ` to `SHAKAPACKER_XYZ`.
|
28
|
+
6. Where you have used webpackConfig, you now need to invoke it as it is a function. Alternatively, you can rename the import to globalMutableWebpackConfig which retains the v6 behavior.
|
29
|
+
7. You may need to upgrade dependencies in package.json. You should use `yarn upgrade-interactive`. Note, some upgrades introduce issues. Some will fix issues. You may need to try a few different versions of a dependency to find one that works.
|
30
|
+
|
31
|
+
|
32
|
+
## The `webpackConfig` property is changed
|
33
|
+
|
34
|
+
The `webpackConfig` property in the `shakapacker` module has been changed. The shakapacker module has two options:
|
35
|
+
1. `generatedWebpackConfig`: a function that returns an immutable webpack configuration object, which ensures that any modifications made to it will not affect any other usage of the webpack configuration.
|
36
|
+
2. `globalMutableWebpackConfig`: if a project still requires the old mutable object. You can rename your imports of `webpackConfig` with `globalMutableWebpackConfig`.
|
37
|
+
|
38
|
+
### Example Upgrade
|
39
|
+
If you started with:
|
40
|
+
|
41
|
+
```js
|
42
|
+
const { webpackConfig } = require('shakapacker')
|
43
|
+
```
|
44
|
+
|
45
|
+
Swtich to:
|
46
|
+
|
47
|
+
```js
|
48
|
+
const { generateWebpackConfig } = require('shakapacker')
|
49
|
+
const webpackConfig = generateWebpackConfig()
|
50
|
+
```
|
51
|
+
|
52
|
+
or use `globalMutableWebpackConfig` if the project desires to use a globally mutable object.
|
53
|
+
|
54
|
+
```js
|
55
|
+
const { globalMutableWebpackConfig: webpackConfig } = require('shakapacker')
|
56
|
+
```
|
@@ -0,0 +1,13 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
ENV["RAILS_ENV"] ||= "development"
|
4
|
+
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile", __FILE__)
|
5
|
+
|
6
|
+
require "bundler/setup"
|
7
|
+
require "shakapacker"
|
8
|
+
require "shakapacker/webpack_runner"
|
9
|
+
|
10
|
+
APP_ROOT = File.expand_path("..", __dir__)
|
11
|
+
Dir.chdir(APP_ROOT) do
|
12
|
+
Shakapacker::WebpackRunner.run(ARGV)
|
13
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
ENV["RAILS_ENV"] ||= "development"
|
4
|
+
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile", __FILE__)
|
5
|
+
|
6
|
+
require "bundler/setup"
|
7
|
+
require "shakapacker"
|
8
|
+
require "shakapacker/dev_server_runner"
|
9
|
+
|
10
|
+
APP_ROOT = File.expand_path("..", __dir__)
|
11
|
+
Dir.chdir(APP_ROOT) do
|
12
|
+
Shakapacker::DevServerRunner.run(ARGV)
|
13
|
+
end
|
@@ -1,15 +1,16 @@
|
|
1
|
-
# Note: You must restart bin/
|
1
|
+
# Note: You must restart bin/shakapacker-dev-server for changes to take effect
|
2
2
|
|
3
3
|
default: &default
|
4
4
|
source_path: app/javascript
|
5
5
|
|
6
6
|
# You can have a subdirectory of the source_path, like 'packs' (recommended).
|
7
7
|
# Alternatively, you can use '/' to use the whole source_path directory.
|
8
|
-
|
8
|
+
# Notice that this is a relative path to source_path
|
9
|
+
source_entry_path: packs
|
9
10
|
|
10
11
|
# If nested_entries is true, then we'll pick up subdirectories within the source_entry_path.
|
11
12
|
# You cannot set this option to true if you set source_entry_path to '/'
|
12
|
-
nested_entries:
|
13
|
+
nested_entries: true
|
13
14
|
|
14
15
|
# While using a File-System-based automated bundle generation feature, miscellaneous warnings suggesting css order
|
15
16
|
# conflicts may arise due to the mini-css-extract-plugin. For projects where css ordering has been mitigated through
|
@@ -19,10 +20,10 @@ default: &default
|
|
19
20
|
|
20
21
|
public_root_path: public
|
21
22
|
public_output_path: packs
|
22
|
-
cache_path: tmp/
|
23
|
+
cache_path: tmp/shakapacker
|
23
24
|
webpack_compile_output: true
|
24
25
|
# See https://github.com/shakacode/shakapacker#deployment
|
25
|
-
|
26
|
+
shakapacker_precompile: true
|
26
27
|
|
27
28
|
# Location for manifest.json, defaults to {public_output_path}/manifest.json if unset
|
28
29
|
# manifest_path: public/packs/manifest.json
|
@@ -51,7 +52,11 @@ development:
|
|
51
52
|
# Reference: https://webpack.js.org/configuration/dev-server/
|
52
53
|
# Keys not described there are documented inline and in https://github.com/shakacode/shakapacker/
|
53
54
|
dev_server:
|
54
|
-
https:
|
55
|
+
# For running dev server with https, set `server: https`.
|
56
|
+
# You may use `https: true` instead but notice that it is deprecated in favor of `server: https`
|
57
|
+
# Ensure only one of these entries is set.
|
58
|
+
# server: https
|
59
|
+
|
55
60
|
host: localhost
|
56
61
|
port: 3035
|
57
62
|
# Hot Module Replacement updates modules while the application is running without a full reload
|
@@ -78,8 +83,8 @@ development:
|
|
78
83
|
# Should we use gzip compression?
|
79
84
|
compress: true
|
80
85
|
# Note that apps that do not check the host are vulnerable to DNS rebinding attacks
|
81
|
-
allowed_hosts: '
|
82
|
-
# Shows progress and colorizes output of bin/
|
86
|
+
allowed_hosts: 'auto'
|
87
|
+
# Shows progress and colorizes output of bin/shakapacker[-dev-server]
|
83
88
|
pretty: true
|
84
89
|
headers:
|
85
90
|
'Access-Control-Allow-Origin': '*'
|
data/lib/install/template.rb
CHANGED
@@ -1,11 +1,11 @@
|
|
1
|
-
# Install
|
2
|
-
copy_file "#{__dir__}/config/
|
1
|
+
# Install Shakapacker
|
2
|
+
copy_file "#{__dir__}/config/shakapacker.yml", "config/shakapacker.yml"
|
3
3
|
copy_file "#{__dir__}/package.json", "package.json"
|
4
4
|
|
5
5
|
say "Copying webpack core config"
|
6
6
|
directory "#{__dir__}/config/webpack", "config/webpack"
|
7
7
|
|
8
|
-
if Dir.exist?(
|
8
|
+
if Dir.exist?(Shakapacker.config.source_path)
|
9
9
|
say "The packs app source directory already exists"
|
10
10
|
else
|
11
11
|
say "Creating packs app source directory"
|
@@ -68,9 +68,9 @@ end
|
|
68
68
|
results = []
|
69
69
|
|
70
70
|
Dir.chdir(Rails.root) do
|
71
|
-
if
|
72
|
-
say "Installing shakapacker@#{
|
73
|
-
results << run("yarn add shakapacker@#{
|
71
|
+
if Shakapacker::VERSION.match?(/^[0-9]+\.[0-9]+\.[0-9]+$/)
|
72
|
+
say "Installing shakapacker@#{Shakapacker::VERSION}"
|
73
|
+
results << run("yarn add shakapacker@#{Shakapacker::VERSION} --exact")
|
74
74
|
else
|
75
75
|
say "Installing shakapacker@next"
|
76
76
|
results << run("yarn add shakapacker@next --exact")
|
@@ -91,6 +91,6 @@ Dir.chdir(Rails.root) do
|
|
91
91
|
end
|
92
92
|
|
93
93
|
unless results.all?
|
94
|
-
say "
|
94
|
+
say "Shakapacker installation failed 😭 See above for details.", :red
|
95
95
|
exit 1
|
96
96
|
end
|
@@ -1,8 +1,8 @@
|
|
1
|
-
class
|
2
|
-
delegate :config, :compiler, :manifest, :logger, to: :@
|
1
|
+
class Shakapacker::Commands
|
2
|
+
delegate :config, :compiler, :manifest, :logger, to: :@instance
|
3
3
|
|
4
|
-
def initialize(
|
5
|
-
@
|
4
|
+
def initialize(instance)
|
5
|
+
@instance = instance
|
6
6
|
end
|
7
7
|
|
8
8
|
# Cleanup old assets in the compile directory. By default it will
|
@@ -1,16 +1,17 @@
|
|
1
1
|
require "open3"
|
2
|
-
require "
|
2
|
+
require "shakapacker/compiler_strategy"
|
3
|
+
require "fileutils"
|
3
4
|
|
4
|
-
class
|
5
|
+
class Shakapacker::Compiler
|
5
6
|
# Additional environment variables that the compiler is being run with
|
6
|
-
#
|
7
|
+
# Shakapacker::Compiler.env['FRONTEND_API_KEY'] = 'your_secret_key'
|
7
8
|
cattr_accessor(:env) { {} }
|
8
9
|
|
9
|
-
delegate :config, :logger, :strategy, to: :
|
10
|
+
delegate :config, :logger, :strategy, to: :instance
|
10
11
|
delegate :fresh?, :stale?, :after_compile_hook, to: :strategy
|
11
12
|
|
12
|
-
def initialize(
|
13
|
-
@
|
13
|
+
def initialize(instance)
|
14
|
+
@instance = instance
|
14
15
|
end
|
15
16
|
|
16
17
|
def compile
|
@@ -32,7 +33,7 @@ class Webpacker::Compiler
|
|
32
33
|
end
|
33
34
|
|
34
35
|
private
|
35
|
-
attr_reader :
|
36
|
+
attr_reader :instance
|
36
37
|
|
37
38
|
def acquire_ipc_lock
|
38
39
|
open_lock_file do |lf|
|
@@ -55,15 +56,24 @@ class Webpacker::Compiler
|
|
55
56
|
end
|
56
57
|
|
57
58
|
def open_lock_file
|
58
|
-
|
59
|
-
|
59
|
+
create_lock_file_dir unless File.exist?(lock_file_path)
|
60
|
+
|
61
|
+
File.open(lock_file_path, File::CREAT) do |lf|
|
60
62
|
return yield lf
|
61
63
|
end
|
62
64
|
end
|
63
65
|
|
66
|
+
def create_lock_file_dir
|
67
|
+
dirname = File.dirname(lock_file_path)
|
68
|
+
FileUtils.mkdir_p(dirname)
|
69
|
+
end
|
70
|
+
|
71
|
+
def lock_file_path
|
72
|
+
config.root_path.join("tmp/shakapacker.lock")
|
73
|
+
end
|
74
|
+
|
64
75
|
def optionalRubyRunner
|
65
|
-
|
66
|
-
first_line = File.readlines(bin_webpack_path).first.chomp
|
76
|
+
first_line = File.readlines(bin_shakapacker_path).first.chomp
|
67
77
|
/ruby/.match?(first_line) ? RbConfig.ruby : ""
|
68
78
|
end
|
69
79
|
|
@@ -72,7 +82,7 @@ class Webpacker::Compiler
|
|
72
82
|
|
73
83
|
stdout, stderr, status = Open3.capture3(
|
74
84
|
webpack_env,
|
75
|
-
"#{optionalRubyRunner}
|
85
|
+
"#{optionalRubyRunner} #{bin_shakapacker_path}",
|
76
86
|
chdir: File.expand_path(config.root_path)
|
77
87
|
)
|
78
88
|
|
@@ -94,8 +104,26 @@ class Webpacker::Compiler
|
|
94
104
|
def webpack_env
|
95
105
|
return env unless defined?(ActionController::Base)
|
96
106
|
|
97
|
-
|
98
|
-
|
99
|
-
|
107
|
+
Shakapacker.set_shakapacker_env_variables_for_backward_compatibility
|
108
|
+
|
109
|
+
env.merge("SHAKAPACKER_ASSET_HOST" => ENV.fetch("SHAKAPACKER_ASSET_HOST", ActionController::Base.helpers.compute_asset_host),
|
110
|
+
"SHAKAPACKER_RELATIVE_URL_ROOT" => ENV.fetch("SHAKAPACKER_RELATIVE_URL_ROOT", ActionController::Base.relative_url_root),
|
111
|
+
"SHAKAPACKER_CONFIG" => instance.config_path.to_s)
|
112
|
+
end
|
113
|
+
|
114
|
+
def bin_shakapacker_path
|
115
|
+
if File.exist?(config.root_path.join("bin/shakapacker"))
|
116
|
+
config.root_path.join("bin/shakapacker")
|
117
|
+
elsif File.exist?(config.root_path.join("bin/webpacker"))
|
118
|
+
Shakapacker.puts_deprecation_message(
|
119
|
+
Shakapacker.short_deprecation_message(
|
120
|
+
"bin/webpacker",
|
121
|
+
"bin/shakapacker"
|
122
|
+
)
|
123
|
+
)
|
124
|
+
config.root_path.join("bin/webpacker")
|
125
|
+
else
|
126
|
+
config.root_path.join("bin/shakapacker")
|
127
|
+
end
|
100
128
|
end
|
101
129
|
end
|
@@ -1,16 +1,16 @@
|
|
1
|
-
require "
|
2
|
-
require "
|
1
|
+
require "shakapacker/mtime_strategy"
|
2
|
+
require "shakapacker/digest_strategy"
|
3
3
|
|
4
|
-
module
|
4
|
+
module Shakapacker
|
5
5
|
class CompilerStrategy
|
6
6
|
def self.from_config
|
7
|
-
strategy_from_config =
|
7
|
+
strategy_from_config = Shakapacker.config.compiler_strategy
|
8
8
|
|
9
9
|
case strategy_from_config
|
10
10
|
when "mtime"
|
11
|
-
|
11
|
+
Shakapacker::MtimeStrategy.new
|
12
12
|
when "digest"
|
13
|
-
|
13
|
+
Shakapacker::DigestStrategy.new
|
14
14
|
else
|
15
15
|
raise "Unknown strategy '#{strategy_from_config}'. " \
|
16
16
|
"Available options are 'mtime' and 'digest'."
|