webpacker 5.0.1 → 5.2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.eslintrc.js +8 -8
- data/.github/workflows/jest.yml +38 -0
- data/.github/workflows/js-lint.yml +39 -0
- data/.github/workflows/rubocop.yml +39 -0
- data/.github/workflows/ruby.yml +66 -0
- data/.node-version +1 -1
- data/.rubocop.yml +113 -13
- data/CHANGELOG.md +32 -3
- data/Gemfile.lock +112 -103
- data/README.md +20 -41
- data/docs/css.md +58 -3
- data/docs/env.md +0 -2
- data/docs/integrations.md +1 -1
- data/docs/target.md +22 -0
- data/docs/testing.md +2 -3
- data/docs/troubleshooting.md +3 -1
- data/docs/typescript.md +92 -27
- data/docs/webpack-dev-server.md +1 -1
- data/lib/install/config/babel.config.js +1 -3
- data/lib/install/config/webpacker.yml +1 -5
- data/lib/install/examples/react/tsconfig.json +2 -1
- data/lib/install/examples/typescript/tsconfig.json +2 -1
- data/lib/install/template.rb +9 -1
- data/lib/install/typescript.rb +6 -13
- data/lib/tasks/webpacker/check_node.rake +1 -1
- data/lib/tasks/webpacker/check_yarn.rake +2 -3
- data/lib/tasks/webpacker/yarn_install.rake +7 -1
- data/lib/webpacker/compiler.rb +9 -5
- data/lib/webpacker/configuration.rb +13 -9
- data/lib/webpacker/dev_server_proxy.rb +3 -1
- data/lib/webpacker/dev_server_runner.rb +2 -2
- data/lib/webpacker/helper.rb +37 -18
- data/lib/webpacker/railtie.rb +0 -43
- data/lib/webpacker/runner.rb +1 -0
- data/lib/webpacker/version.rb +1 -1
- data/lib/webpacker/webpack_runner.rb +2 -2
- data/package.json +35 -35
- data/package/__tests__/config.js +12 -1
- data/package/__tests__/dev_server.js +2 -0
- data/package/__tests__/development.js +14 -1
- data/package/config.js +4 -1
- data/package/configPath.js +3 -0
- data/package/dev_server.js +1 -1
- data/package/env.js +1 -2
- data/package/environments/__tests__/base.js +25 -8
- data/package/environments/base.js +5 -6
- data/package/environments/development.js +39 -33
- data/package/environments/production.js +1 -3
- data/package/rules/babel.js +12 -5
- data/package/rules/file.js +3 -2
- data/package/rules/node_modules.js +1 -3
- data/package/rules/sass.js +4 -1
- data/package/utils/helpers.js +1 -1
- data/test/compiler_test.rb +8 -3
- data/test/configuration_test.rb +8 -7
- data/test/dev_server_runner_test.rb +1 -1
- data/test/helper_test.rb +3 -0
- data/test/test_app/config/application.rb +0 -1
- data/test/test_app/config/webpacker.yml +7 -1
- data/test/test_app/public/packs/manifest.json +1 -0
- data/test/webpack_runner_test.rb +1 -1
- data/webpacker.gemspec +1 -1
- data/yarn.lock +3296 -3594
- metadata +19 -14
- data/lib/install/loaders/typescript.js +0 -11
data/docs/env.md
CHANGED
@@ -49,8 +49,6 @@ dotenvFiles.forEach((dotenvFile) => {
|
|
49
49
|
dotenv.config({ path: dotenvFile, silent: true })
|
50
50
|
})
|
51
51
|
|
52
|
-
environment.plugins.prepend('Environment', new webpack.EnvironmentPlugin(JSON.parse(JSON.stringify(process.env))))
|
53
|
-
|
54
52
|
module.exports = environment
|
55
53
|
```
|
56
54
|
|
data/docs/integrations.md
CHANGED
@@ -91,7 +91,7 @@ You can read more about this in the [Vue docs](https://vuejs.org/v2/guide/instal
|
|
91
91
|
|
92
92
|
### Lazy loading integration
|
93
93
|
|
94
|
-
See [docs/es6](
|
94
|
+
See [docs/es6](es6.md) to know more about Webpack and Webpacker configuration.
|
95
95
|
|
96
96
|
For instance, you can lazy load Vue JS components:
|
97
97
|
|
data/docs/target.md
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
# Target browsers
|
2
|
+
|
3
|
+
By default webpacker provides these front-end tools:
|
4
|
+
- [@babel/preset-env](https://github.com/babel/babel/tree/master/packages/babel-preset-env)
|
5
|
+
- [Autoprefixer](https://github.com/postcss/autoprefixer)
|
6
|
+
- [postcss-preset-env](https://github.com/csstools/postcss-preset-env)
|
7
|
+
|
8
|
+
All these tools use [Browserslist](https://github.com/browserslist/browserslist) to detect which environment your users have
|
9
|
+
|
10
|
+
Webpacker browserslist default target:
|
11
|
+
```
|
12
|
+
defaults
|
13
|
+
```
|
14
|
+
|
15
|
+
`defaults`: `(> 0.5%, last 2 versions, Firefox ESR, not dead)`, [browserl.ist](https://browserl.ist/) is an online tool to check what browsers will be selected by some query.
|
16
|
+
|
17
|
+
To keep browsers data up to date, you need to run:
|
18
|
+
```bash
|
19
|
+
yarn upgrade caniuse-lite
|
20
|
+
```
|
21
|
+
|
22
|
+
at least once every few months, to prevent such [problems](https://github.com/browserslist/browserslist/issues/492)
|
data/docs/testing.md
CHANGED
@@ -10,8 +10,7 @@ Webpacker does not setup `Karma` by default, so you've to manually install it al
|
|
10
10
|
"test": "NODE_ENV=test karma start"
|
11
11
|
},
|
12
12
|
"dependencies": {
|
13
|
-
"typescript": "^2.5.2"
|
14
|
-
"ts-loader": "^2.3.7"
|
13
|
+
"typescript": "^2.5.2"
|
15
14
|
},
|
16
15
|
"devDependencies": {
|
17
16
|
"karma": "^1.7.1",
|
@@ -33,7 +32,7 @@ It is beneficial to use the same webpack configuration file (generated by webpac
|
|
33
32
|
```js
|
34
33
|
// config/webpack/test.js
|
35
34
|
const environment = require('./environment')
|
36
|
-
environment.plugins.get('Manifest').
|
35
|
+
environment.plugins.get('Manifest').options.writeToFileEmit = process.env.NODE_ENV !== 'test'
|
37
36
|
environment.loaders.append('istanbul-instrumenter', {
|
38
37
|
test: /\.ts$/,
|
39
38
|
enforce: "post",
|
data/docs/troubleshooting.md
CHANGED
@@ -4,11 +4,13 @@
|
|
4
4
|
|
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
|
-
2. Put a `debugger` statement in your Webpack configuration and run `bin/webpack --debug`.
|
7
|
+
2. Put a `debugger` statement in your Webpack configuration and run `bin/webpack --debug-webpacker`.
|
8
8
|
If you have a node debugger installed, you'll see the Chrome debugger for your webpack
|
9
9
|
config. For example, install the Chrome extension [NiM](https://chrome.google.com/webstore/detail/nodejs-v8-inspector-manag/gnhhdgbaldcilmgcpfddgdbkhjohddkj) and
|
10
10
|
set the option for the dev tools to open automatically. For more details on debugging,
|
11
11
|
see the official [Webpack docs on debugging](https://webpack.js.org/contribute/debugging/#devtools)
|
12
|
+
3. Any arguments that you add to bin/webpack 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.
|
13
|
+
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-webpacker`
|
12
14
|
|
13
15
|
## ENOENT: no such file or directory - node-sass
|
14
16
|
|
data/docs/typescript.md
CHANGED
@@ -1,18 +1,98 @@
|
|
1
|
-
#
|
1
|
+
# TypeScript
|
2
2
|
|
3
|
+
## Installation
|
3
4
|
|
4
|
-
|
5
|
+
1. Run the TypeScript installer
|
5
6
|
|
6
|
-
|
7
|
+
```bash
|
8
|
+
bundle exec rails webpacker:install:typescript
|
9
|
+
```
|
10
|
+
|
11
|
+
After that, a new file called `hello_typescript.ts` will be present in your `packs` directory (or rather the `source_entry_path` of your `webpacker.yml` configuration). You're now ready to write TypeScript.
|
12
|
+
|
13
|
+
## (Optional) Adding Compile-Time Type Checking
|
14
|
+
|
15
|
+
The default installation only transpiles your TypeScript code using Babel. If you would like to enable type checking as part of the Webpack compilation process (i.e. fail the build if there are TS errors), you can do the following:
|
16
|
+
|
17
|
+
1. Install the Fork TS Checker Webpack Plugin
|
18
|
+
|
19
|
+
```sh
|
20
|
+
yarn add --dev fork-ts-checker-webpack-plugin
|
21
|
+
```
|
22
|
+
|
23
|
+
2. Then add it to your development environment config in `config/webpack/development.js`
|
24
|
+
|
25
|
+
```js
|
26
|
+
const ForkTsCheckerWebpackPlugin = require("fork-ts-checker-webpack-plugin");
|
27
|
+
const path = require("path");
|
28
|
+
|
29
|
+
environment.plugins.append(
|
30
|
+
"ForkTsCheckerWebpackPlugin",
|
31
|
+
new ForkTsCheckerWebpackPlugin({
|
32
|
+
typescript: {
|
33
|
+
configFile: path.resolve(__dirname, "../../tsconfig.json"),
|
34
|
+
},
|
35
|
+
async: false,
|
36
|
+
})
|
37
|
+
);
|
38
|
+
```
|
39
|
+
|
40
|
+
If you are `fork-ts-checker-webpack-plugin` older than 5.0, the `tsconfig` option also needs to be specified:
|
41
|
+
|
42
|
+
```js
|
43
|
+
const ForkTsCheckerWebpackPlugin = require("fork-ts-checker-webpack-plugin");
|
44
|
+
const path = require("path");
|
45
|
+
|
46
|
+
environment.plugins.append(
|
47
|
+
"ForkTsCheckerWebpackPlugin",
|
48
|
+
new ForkTsCheckerWebpackPlugin({
|
49
|
+
// this is a relative path to your project's TypeScript config
|
50
|
+
tsconfig: path.resolve(__dirname, "../../tsconfig.json"),
|
51
|
+
// non-async so type checking will block compilation
|
52
|
+
async: false,
|
53
|
+
})
|
54
|
+
);
|
55
|
+
```
|
56
|
+
|
57
|
+
## Upgrading to 5.1
|
58
|
+
|
59
|
+
If you update your App to `webpacker >= 5.1` and had TypeScript installed before, you need to add some new/remove some old configurations:
|
60
|
+
|
61
|
+
1. Remove old packages:
|
62
|
+
- `yarn remove ts-loader`
|
63
|
+
|
64
|
+
2. Add new packages:
|
65
|
+
- `yarn add @babel/preset-typescript`
|
66
|
+
|
67
|
+
3. Remove old configuration files:
|
68
|
+
- Delete this file: `config/webpack/loaders/typescript.js`
|
69
|
+
|
70
|
+
4. Remove the following lines from `config/webpack/environment.js`:
|
71
|
+
- `const typescript = require('./loaders/typescript')`
|
72
|
+
- `environment.loaders.prepend('typescript', typescript)`
|
73
|
+
|
74
|
+
5. Add the TypeScript preset to your `babel.config.js`:
|
75
|
+
- This line `['@babel/preset-typescript', { 'allExtensions': true, 'isTSX': true }]` has to be added as the last item to the `presets` array in your `babel.config.js`
|
76
|
+
|
77
|
+
### Upgrading to 5.1 for Vue users
|
78
|
+
|
79
|
+
1. Remove old packages:
|
80
|
+
- `yarn remove ts-loader pnp-webpack-plugin`
|
81
|
+
|
82
|
+
2. Follow point 3 and 4 from the `TypeScript with Vue components` section
|
83
|
+
|
84
|
+
## TypeScript with React
|
85
|
+
|
86
|
+
1. Setup react using Webpacker [react installer](../README.md#react). Then run the TypeScript installer
|
7
87
|
|
8
88
|
```bash
|
9
89
|
bundle exec rails webpacker:install:typescript
|
10
90
|
```
|
11
91
|
|
12
|
-
2. Rename the generated `hello_react.js` to `hello_react.tsx`. Make the file valid
|
13
|
-
now you can use
|
92
|
+
2. Rename the generated `hello_react.js` to `hello_react.tsx`. Make the file valid TypeScript and
|
93
|
+
now you can use TypeScript, JSX with React.
|
14
94
|
|
15
|
-
##
|
95
|
+
## TypeScript with Vue components
|
16
96
|
|
17
97
|
1. Setup Vue using the Webpacker [Vue installer](../README.md#vue). Then run the TypeScript installer
|
18
98
|
|
@@ -21,37 +101,22 @@ bundle exec rails webpacker:install:typescript
|
|
21
101
|
```
|
22
102
|
|
23
103
|
2. Rename generated `hello_vue.js` to `hello_vue.ts`.
|
24
|
-
3.
|
25
|
-
4. Change the generated `config
|
104
|
+
3. Install the right Babel preset: `yarn add babel-preset-typescript-vue`
|
105
|
+
4. Change the generated `babel.config.js` from
|
26
106
|
|
27
107
|
```js
|
28
|
-
|
29
|
-
test: /\.tsx?(\.erb)?$/,
|
30
|
-
use: [{
|
31
|
-
loader: 'ts-loader'
|
32
|
-
}]
|
33
|
-
}
|
108
|
+
["@babel/preset-typescript", { "allExtensions": true, "isTSX": true }]
|
34
109
|
```
|
35
110
|
|
36
111
|
to
|
37
112
|
|
38
113
|
```js
|
39
|
-
|
40
|
-
|
41
|
-
module.exports = {
|
42
|
-
test: /\.tsx?(\.erb)?$/,
|
43
|
-
use: [{
|
44
|
-
loader: 'ts-loader',
|
45
|
-
options: PnpWebpackPlugin.tsLoaderOptions({
|
46
|
-
appendTsSuffixTo: [/\.vue$/]
|
47
|
-
})
|
48
|
-
}]
|
49
|
-
}
|
114
|
+
["babel-preset-typescript-vue", { "allExtensions": true, "isTSX": true }]
|
50
115
|
```
|
51
116
|
|
52
|
-
and now you can use `<script lang="ts">` in your `.vue` component files. See [the
|
117
|
+
and now you can use `<script lang="ts">` in your `.vue` component files. See [the babel-preset-typescript-vue docs](https://www.npmjs.com/package/babel-preset-typescript-vue) for more info.
|
53
118
|
|
54
|
-
## HTML templates with
|
119
|
+
## HTML templates with TypeScript and Angular
|
55
120
|
|
56
121
|
After you have installed Angular using `bundle exec rails webpacker:install:angular`
|
57
122
|
you would need to follow these steps to add HTML templates support:
|
data/docs/webpack-dev-server.md
CHANGED
@@ -19,7 +19,7 @@ Now if you refresh your Rails view everything should work as expected.
|
|
19
19
|
Webpacker out-of-the-box supports HMR with `webpack-dev-server` and
|
20
20
|
you can toggle it by setting `dev_server/hmr` option inside `webpacker.yml`.
|
21
21
|
|
22
|
-
|
22
|
+
Check out this guide for more information:
|
23
23
|
|
24
24
|
- https://webpack.js.org/configuration/dev-server/#devserver-hot
|
25
25
|
|
@@ -6,12 +6,11 @@ default: &default
|
|
6
6
|
public_root_path: public
|
7
7
|
public_output_path: packs
|
8
8
|
cache_path: tmp/cache/webpacker
|
9
|
-
check_yarn_integrity: false
|
10
9
|
webpack_compile_output: true
|
11
10
|
|
12
11
|
# Additional paths webpack should lookup modules
|
13
12
|
# ['app/assets', 'engine/foo/app/assets']
|
14
|
-
|
13
|
+
additional_paths: []
|
15
14
|
|
16
15
|
# Reload manifest.json on all requests so we reload latest compiled packs
|
17
16
|
cache_manifest: false
|
@@ -52,9 +51,6 @@ development:
|
|
52
51
|
<<: *default
|
53
52
|
compile: true
|
54
53
|
|
55
|
-
# Verifies that correct packages and versions are installed by inspecting package.json, yarn.lock, and node_modules
|
56
|
-
check_yarn_integrity: true
|
57
|
-
|
58
54
|
# Reference: https://webpack.js.org/configuration/dev-server/
|
59
55
|
dev_server:
|
60
56
|
https: false
|
data/lib/install/template.rb
CHANGED
@@ -34,7 +34,7 @@ if File.exists?(".gitignore")
|
|
34
34
|
end
|
35
35
|
end
|
36
36
|
|
37
|
-
if Webpacker::VERSION
|
37
|
+
if Webpacker::VERSION.match?(/^[0-9]+\.[0-9]+\.[0-9]+$/)
|
38
38
|
say "Installing all JavaScript dependencies [#{Webpacker::VERSION}]"
|
39
39
|
run "yarn add @rails/webpacker@#{Webpacker::VERSION}"
|
40
40
|
else
|
@@ -42,6 +42,14 @@ else
|
|
42
42
|
run "yarn add @rails/webpacker@next"
|
43
43
|
end
|
44
44
|
|
45
|
+
package_json = File.read("#{__dir__}/../../package.json")
|
46
|
+
webpack_version = package_json.match(/"webpack": "(.*)"/)[1]
|
47
|
+
webpack_cli_version = package_json.match(/"webpack-cli": "(.*)"/)[1]
|
48
|
+
|
49
|
+
# needed for experimental Yarn 2 support and should not harm Yarn 1
|
50
|
+
say "Installing webpack and webpack-cli as direct dependencies"
|
51
|
+
run "yarn add webpack@#{webpack_version} webpack-cli@#{webpack_cli_version}"
|
52
|
+
|
45
53
|
say "Installing dev server for live reloading"
|
46
54
|
run "yarn add --dev webpack-dev-server"
|
47
55
|
|
data/lib/install/typescript.rb
CHANGED
@@ -9,23 +9,16 @@ if File.exist?(package_json)
|
|
9
9
|
package = JSON.parse(File.read(package_json))
|
10
10
|
package["dependencies"] ||= {}
|
11
11
|
|
12
|
-
if package["dependencies"].
|
12
|
+
if package["dependencies"].key?("react")
|
13
13
|
additional_packages = "@types/react @types/react-dom"
|
14
14
|
example_source = "react"
|
15
15
|
end
|
16
16
|
end
|
17
17
|
|
18
|
-
say "
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
insert_into_file Rails.root.join("config/webpack/environment.js").to_s,
|
23
|
-
"const typescript = require('./loaders/typescript')\n",
|
24
|
-
after: /require\(('|")@rails\/webpacker\1\);?\n/
|
25
|
-
|
26
|
-
insert_into_file Rails.root.join("config/webpack/environment.js").to_s,
|
27
|
-
"environment.loaders.prepend('typescript', typescript)\n",
|
28
|
-
before: "module.exports"
|
18
|
+
say "Adding TypeScript preset to babel.config.js"
|
19
|
+
insert_into_file Rails.root.join("babel.config.js").to_s,
|
20
|
+
",\n ['@babel/preset-typescript', { 'allExtensions': true, 'isTSX': true }]",
|
21
|
+
before: /\s*\].filter\(Boolean\),\n\s*plugins: \[/
|
29
22
|
|
30
23
|
say "Copying tsconfig.json to the Rails root directory for typescript"
|
31
24
|
copy_file "#{__dir__}/examples/#{example_source}/tsconfig.json", "tsconfig.json"
|
@@ -41,6 +34,6 @@ copy_file "#{__dir__}/examples/typescript/hello_typescript.ts",
|
|
41
34
|
"#{Webpacker.config.source_entry_path}/hello_typescript.ts"
|
42
35
|
|
43
36
|
say "Installing all typescript dependencies"
|
44
|
-
run "yarn add typescript
|
37
|
+
run "yarn add typescript @babel/preset-typescript #{additional_packages}"
|
45
38
|
|
46
39
|
say "Webpacker now supports typescript 🎉", :green
|
@@ -3,7 +3,7 @@ namespace :webpacker do
|
|
3
3
|
desc "Verifies if Node.js is installed"
|
4
4
|
task :check_node do
|
5
5
|
begin
|
6
|
-
node_version = `node -v || nodejs -v
|
6
|
+
node_version = `node -v || nodejs -v`.strip
|
7
7
|
raise Errno::ENOENT if node_version.blank?
|
8
8
|
|
9
9
|
pkg_path = Pathname.new("#{__dir__}/../../../package.json").realpath
|
@@ -3,19 +3,18 @@ namespace :webpacker do
|
|
3
3
|
desc "Verifies if Yarn is installed"
|
4
4
|
task :check_yarn do
|
5
5
|
begin
|
6
|
-
yarn_version = `yarn --version
|
6
|
+
yarn_version = `yarn --version`.strip
|
7
7
|
raise Errno::ENOENT if yarn_version.blank?
|
8
8
|
|
9
9
|
pkg_path = Pathname.new("#{__dir__}/../../../package.json").realpath
|
10
10
|
yarn_range = JSON.parse(pkg_path.read)["engines"]["yarn"]
|
11
11
|
is_valid = SemanticRange.satisfies?(yarn_version, yarn_range) rescue false
|
12
|
-
is_unsupported = SemanticRange.satisfies?(yarn_version, ">=
|
12
|
+
is_unsupported = SemanticRange.satisfies?(yarn_version, ">=3.0.0") rescue false
|
13
13
|
|
14
14
|
unless is_valid
|
15
15
|
$stderr.puts "Webpacker requires Yarn \"#{yarn_range}\" and you are using #{yarn_version}"
|
16
16
|
if is_unsupported
|
17
17
|
$stderr.puts "This version of Webpacker does not support Yarn #{yarn_version}. Please downgrade to a supported version of Yarn https://yarnpkg.com/lang/en/docs/install/"
|
18
|
-
$stderr.puts "For information on using Webpacker with Yarn 2.0, see https://github.com/rails/webpacker/issues/2112"
|
19
18
|
else
|
20
19
|
$stderr.puts "Please upgrade Yarn https://yarnpkg.com/lang/en/docs/install/"
|
21
20
|
end
|
@@ -5,6 +5,12 @@ namespace :webpacker do
|
|
5
5
|
node_env = ENV.fetch("NODE_ENV") do
|
6
6
|
valid_node_envs.include?(Rails.env) ? Rails.env : "production"
|
7
7
|
end
|
8
|
-
|
8
|
+
yarn_flags =
|
9
|
+
if `yarn --version`.start_with?("1")
|
10
|
+
"--no-progress --frozen-lockfile"
|
11
|
+
else
|
12
|
+
"--immutable"
|
13
|
+
end
|
14
|
+
system({ "NODE_ENV" => node_env }, "yarn install #{yarn_flags}")
|
9
15
|
end
|
10
16
|
end
|
data/lib/webpacker/compiler.rb
CHANGED
@@ -4,6 +4,8 @@ require "digest/sha1"
|
|
4
4
|
class Webpacker::Compiler
|
5
5
|
# Additional paths that test compiler needs to watch
|
6
6
|
# Webpacker::Compiler.watched_paths << 'bower_components'
|
7
|
+
#
|
8
|
+
# Deprecated. Use additional_paths in the YAML configuration instead.
|
7
9
|
cattr_accessor(:watched_paths) { [] }
|
8
10
|
|
9
11
|
# Additional environment variables that the compiler is being run with
|
@@ -20,9 +22,8 @@ class Webpacker::Compiler
|
|
20
22
|
if stale?
|
21
23
|
run_webpack.tap do |success|
|
22
24
|
# We used to only record the digest on success
|
23
|
-
# However, the output file is still written on error,
|
24
|
-
#
|
25
|
-
# take place when it should.
|
25
|
+
# However, the output file is still written on error, meaning that the digest should still be updated.
|
26
|
+
# If it's not, you can end up in a situation where a recompile doesn't take place when it should.
|
26
27
|
# See https://github.com/rails/webpacker/issues/2113
|
27
28
|
record_compilation_digest
|
28
29
|
end
|
@@ -51,6 +52,8 @@ class Webpacker::Compiler
|
|
51
52
|
end
|
52
53
|
|
53
54
|
def watched_files_digest
|
55
|
+
warn "Webpacker::Compiler.watched_paths has been deprecated. Set additional_paths in webpacker.yml instead." unless watched_paths.empty?
|
56
|
+
|
54
57
|
files = Dir[*default_watched_paths, *watched_paths].reject { |f| File.directory?(f) }
|
55
58
|
file_ids = files.sort.map { |f| "#{File.basename(f)}/#{Digest::SHA1.file(f).hexdigest}" }
|
56
59
|
Digest::SHA1.hexdigest(file_ids.join("/"))
|
@@ -87,7 +90,7 @@ class Webpacker::Compiler
|
|
87
90
|
|
88
91
|
def default_watched_paths
|
89
92
|
[
|
90
|
-
*config.
|
93
|
+
*config.additional_paths_globbed,
|
91
94
|
config.source_path_globbed,
|
92
95
|
"yarn.lock", "package.json",
|
93
96
|
"config/webpack/**/*"
|
@@ -102,6 +105,7 @@ class Webpacker::Compiler
|
|
102
105
|
return env unless defined?(ActionController::Base)
|
103
106
|
|
104
107
|
env.merge("WEBPACKER_ASSET_HOST" => ENV.fetch("WEBPACKER_ASSET_HOST", ActionController::Base.helpers.compute_asset_host),
|
105
|
-
"WEBPACKER_RELATIVE_URL_ROOT" => ENV.fetch("WEBPACKER_RELATIVE_URL_ROOT", ActionController::Base.relative_url_root)
|
108
|
+
"WEBPACKER_RELATIVE_URL_ROOT" => ENV.fetch("WEBPACKER_RELATIVE_URL_ROOT", ActionController::Base.relative_url_root),
|
109
|
+
"WEBPACKER_CONFIG" => webpacker.config_path.to_s)
|
106
110
|
end
|
107
111
|
end
|