webpacker 4.0.7 → 5.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.node-version +1 -1
- data/.rubocop.yml +2 -1
- data/.travis.yml +10 -20
- data/CHANGELOG.md +243 -137
- data/Gemfile +1 -0
- data/Gemfile.lock +84 -62
- data/README.md +52 -149
- data/docs/css.md +15 -4
- data/docs/deployment.md +40 -11
- data/docs/docker.md +33 -14
- data/docs/engines.md +53 -3
- data/docs/es6.md +19 -1
- data/docs/integrations.md +220 -0
- data/docs/troubleshooting.md +37 -9
- data/docs/typescript.md +10 -8
- data/docs/webpack-dev-server.md +1 -1
- data/docs/webpack.md +18 -3
- data/gemfiles/{Gemfile-rails.4.2.x → Gemfile-rails.6.0.x} +1 -1
- data/lib/install/bin/webpack +0 -1
- data/lib/install/bin/webpack-dev-server +0 -1
- data/lib/install/coffee.rb +1 -1
- data/lib/install/config/babel.config.js +10 -10
- data/lib/install/config/webpacker.yml +2 -1
- data/lib/install/elm.rb +1 -1
- data/lib/install/erb.rb +2 -2
- data/lib/install/examples/angular/hello_angular/polyfills.ts +2 -2
- data/lib/install/examples/react/babel.config.js +16 -14
- data/lib/install/examples/svelte/app.svelte +11 -0
- data/lib/install/examples/svelte/hello_svelte.js +20 -0
- data/lib/install/loaders/elm.js +9 -6
- data/lib/install/loaders/svelte.js +9 -0
- data/lib/install/loaders/typescript.js +1 -1
- data/lib/install/svelte.rb +29 -0
- data/lib/install/template.rb +2 -2
- data/lib/install/typescript.rb +1 -1
- data/lib/install/vue.rb +1 -1
- data/lib/tasks/installers.rake +1 -0
- data/lib/tasks/webpacker.rake +2 -0
- data/lib/tasks/webpacker/check_node.rake +14 -7
- data/lib/tasks/webpacker/check_yarn.rake +16 -9
- data/lib/tasks/webpacker/clean.rake +25 -0
- data/lib/tasks/webpacker/clobber.rake +8 -4
- data/lib/tasks/webpacker/compile.rake +2 -10
- data/lib/tasks/webpacker/yarn_install.rake +5 -1
- data/lib/webpacker.rb +9 -1
- data/lib/webpacker/commands.rb +53 -1
- data/lib/webpacker/compiler.rb +15 -8
- data/lib/webpacker/configuration.rb +9 -1
- data/lib/webpacker/dev_server.rb +1 -1
- data/lib/webpacker/dev_server_proxy.rb +2 -8
- data/lib/webpacker/dev_server_runner.rb +4 -4
- data/lib/webpacker/env.rb +1 -1
- data/lib/webpacker/helper.rb +39 -13
- data/lib/webpacker/manifest.rb +4 -4
- data/lib/webpacker/railtie.rb +6 -0
- data/lib/webpacker/version.rb +1 -1
- data/package.json +38 -38
- data/package/__tests__/config.js +0 -23
- data/package/config.js +2 -10
- data/package/config_types/config_list.js +3 -3
- data/package/config_types/config_object.js +1 -1
- data/package/environments/__tests__/base.js +10 -0
- data/package/environments/base.js +14 -3
- data/package/environments/development.js +1 -5
- data/package/environments/production.js +12 -0
- data/package/rules/babel.js +1 -1
- data/package/rules/node_modules.js +2 -2
- data/package/rules/sass.js +3 -2
- data/package/utils/__tests__/get_style_rule.js +9 -0
- data/package/utils/deep_merge.js +5 -5
- data/package/utils/get_style_rule.js +7 -12
- data/package/utils/helpers.js +9 -9
- data/test/command_test.rb +6 -0
- data/test/compiler_test.rb +5 -6
- data/test/configuration_test.rb +36 -27
- data/test/dev_server_test.rb +22 -0
- data/test/helper_test.rb +34 -0
- data/test/manifest_test.rb +37 -6
- data/test/rake_tasks_test.rb +17 -0
- data/test/test_app/app/javascript/packs/multi_entry.css +4 -0
- data/test/test_app/app/javascript/packs/multi_entry.js +4 -0
- data/test/test_app/bin/webpack +0 -1
- data/test/test_app/bin/webpack-dev-server +0 -1
- data/test/test_app/config/webpacker.yml +1 -0
- data/test/test_app/public/packs/manifest.json +3 -0
- data/webpacker.gemspec +5 -3
- data/yarn.lock +2684 -1846
- metadata +48 -12
- data/gemfiles/Gemfile-rails.5.0.x +0 -9
- data/gemfiles/Gemfile-rails.5.1.x +0 -9
data/docs/troubleshooting.md
CHANGED
@@ -4,22 +4,36 @@
|
|
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`.
|
8
8
|
If you have a node debugger installed, you'll see the Chrome debugger for your webpack
|
9
|
-
config. For example, install the Chrome extension [NiM](https://chrome.google.com/webstore/detail/nodejs-v8-inspector-manag/gnhhdgbaldcilmgcpfddgdbkhjohddkj) and
|
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
12
|
|
13
13
|
## ENOENT: no such file or directory - node-sass
|
14
14
|
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
basically, it can't find the `node-sass` binary.
|
19
|
-
An easy solution is to create a postinstall hook - `npm rebuild node-sass` in
|
20
|
-
`package.json` and that will ensure `node-sass` is rebuilt whenever
|
21
|
-
you install any new modules.
|
15
|
+
If you get the error `ENOENT: no such file or directory - node-sass` on deploy with
|
16
|
+
`assets:precompile` or `bundle exec rails webpacker:compile` you may need to
|
17
|
+
move Sass to production `dependencies`.
|
22
18
|
|
19
|
+
Move any packages that related to Sass (e.g. `node-sass` or `sass-loader`) from
|
20
|
+
`devDependencies` to `dependencies` in `package.json`. This is because
|
21
|
+
webpacker is running on a production system with the Rails workflow to build
|
22
|
+
the assets. Particularly on hosting providers that try to detect and do the right
|
23
|
+
thing, like Heroku.
|
24
|
+
|
25
|
+
However, if you get this on local development, or not during a deploy then you
|
26
|
+
may need to rebuild `node-sass`. It's a bit of a weird error; basically, it
|
27
|
+
can't find the `node-sass` binary. An easy solution is to create a postinstall
|
28
|
+
hook to ensure `node-sass` is rebuilt whenever new modules are installed.
|
29
|
+
|
30
|
+
In `package.json`:
|
31
|
+
|
32
|
+
```json
|
33
|
+
"scripts": {
|
34
|
+
"postinstall": "npm rebuild node-sass"
|
35
|
+
}
|
36
|
+
```
|
23
37
|
|
24
38
|
## Can't find hello_react.js in manifest.json
|
25
39
|
|
@@ -126,3 +140,17 @@ environment.plugins.append('ContextReplacement',
|
|
126
140
|
)
|
127
141
|
)
|
128
142
|
```
|
143
|
+
|
144
|
+
### Compilation Fails Silently
|
145
|
+
|
146
|
+
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 webpacker.yml may add some helpful error information to your log file (Rails log/development.log or log/production.log)
|
147
|
+
|
148
|
+
```yml
|
149
|
+
# webpacker.yml
|
150
|
+
default: &default
|
151
|
+
source_path: app/javascript
|
152
|
+
source_entry_path: packs
|
153
|
+
public_root_path: public
|
154
|
+
public_output_path: complaints_packs
|
155
|
+
webpack_compile_output: true
|
156
|
+
```
|
data/docs/typescript.md
CHANGED
@@ -7,7 +7,6 @@
|
|
7
7
|
|
8
8
|
```bash
|
9
9
|
bundle exec rails webpacker:install:typescript
|
10
|
-
yarn add @types/react @types/react-dom
|
11
10
|
```
|
12
11
|
|
13
12
|
2. Rename the generated `hello_react.js` to `hello_react.tsx`. Make the file valid typescript and
|
@@ -15,18 +14,19 @@ now you can use typescript, JSX with React.
|
|
15
14
|
|
16
15
|
## Typescript with Vue components
|
17
16
|
|
18
|
-
1. Setup
|
17
|
+
1. Setup Vue using the Webpacker [Vue installer](../README.md#vue). Then run the TypeScript installer
|
19
18
|
|
20
19
|
```bash
|
21
20
|
bundle exec rails webpacker:install:typescript
|
22
21
|
```
|
23
22
|
|
24
23
|
2. Rename generated `hello_vue.js` to `hello_vue.ts`.
|
25
|
-
3.
|
24
|
+
3. Add the webpack plug-n-play plugin to your yarn packages with `yarn add pnp-webpack-plugin`.
|
25
|
+
4. Change the generated `config/webpack/loaders/typescript.js` from
|
26
26
|
|
27
27
|
```js
|
28
28
|
module.exports = {
|
29
|
-
test: /\.
|
29
|
+
test: /\.tsx?(\.erb)?$/,
|
30
30
|
use: [{
|
31
31
|
loader: 'ts-loader'
|
32
32
|
}]
|
@@ -36,18 +36,20 @@ module.exports = {
|
|
36
36
|
to
|
37
37
|
|
38
38
|
```js
|
39
|
+
const PnpWebpackPlugin = require('pnp-webpack-plugin');
|
40
|
+
|
39
41
|
module.exports = {
|
40
|
-
test: /\.
|
42
|
+
test: /\.tsx?(\.erb)?$/,
|
41
43
|
use: [{
|
42
44
|
loader: 'ts-loader',
|
43
|
-
options: {
|
45
|
+
options: PnpWebpackPlugin.tsLoaderOptions({
|
44
46
|
appendTsSuffixTo: [/\.vue$/]
|
45
|
-
}
|
47
|
+
})
|
46
48
|
}]
|
47
49
|
}
|
48
50
|
```
|
49
51
|
|
50
|
-
and now you can use `<script lang="ts">` in your `.vue` component files.
|
52
|
+
and now you can use `<script lang="ts">` in your `.vue` component files. See [the pnp-webpack-plugin docs for the `ts-loader` integration](https://github.com/arcanis/pnp-webpack-plugin#ts-loader-integration) for more info.
|
51
53
|
|
52
54
|
## HTML templates with Typescript and Angular
|
53
55
|
|
data/docs/webpack-dev-server.md
CHANGED
@@ -38,7 +38,7 @@ If you use Nginx in development to proxy requests to your Rails server from
|
|
38
38
|
another domain, like `myapp.dev`, the Webpacker middleware will be able to
|
39
39
|
forward requests for "packs" to the webpack dev server.
|
40
40
|
|
41
|
-
If you're using `inline` mode
|
41
|
+
If you're using `inline` mode behind Nginx, you may also need to provide the
|
42
42
|
hostname to webpack dev server so it can initiate the websocket connection for
|
43
43
|
live reloading ([Webpack
|
44
44
|
docs](https://webpack.js.org/configuration/dev-server/#devserver-public)).
|
data/docs/webpack.md
CHANGED
@@ -189,9 +189,10 @@ const { environment } = require('@rails/webpacker')
|
|
189
189
|
const merge = require('webpack-merge')
|
190
190
|
|
191
191
|
const myCssLoaderOptions = {
|
192
|
-
modules:
|
192
|
+
modules: {
|
193
|
+
localIdentName: '[name]__[local]___[hash:base64:5]'
|
194
|
+
},
|
193
195
|
sourceMap: true,
|
194
|
-
localIdentName: '[name]__[local]___[hash:base64:5]'
|
195
196
|
}
|
196
197
|
|
197
198
|
const CSSLoader = environment.loaders.get('sass').use.find(el => el.loader === 'css-loader')
|
@@ -277,7 +278,7 @@ environment.splitChunks()
|
|
277
278
|
environment.splitChunks((config) => Object.assign({}, config, { optimization: { splitChunks: false }}))
|
278
279
|
```
|
279
280
|
|
280
|
-
Then use
|
281
|
+
Then use the `javascript_packs_with_chunks_tag` and `stylesheet_packs_with_chunks_tag` helpers to include all the transpiled
|
281
282
|
packs with the chunks in your view, which creates html tags for all the chunks.
|
282
283
|
|
283
284
|
```erb
|
@@ -304,6 +305,20 @@ get duplicated chunks on the page.
|
|
304
305
|
|
305
306
|
For the old configuration with the CommonsChunkPlugin see below. **Note** that this functionality is deprecated in Webpack V4.
|
306
307
|
|
308
|
+
#### Preloading
|
309
|
+
|
310
|
+
Before preload or prefetch your assets, please read [https://developer.mozilla.org/en-US/docs/Web/HTML/Preloading_content](https://developer.mozilla.org/en-US/docs/Web/HTML/Preloading_content).
|
311
|
+
|
312
|
+
Webpack also provide it's own methods for preload or prefetch [https://medium.com/webpack/link-rel-prefetch-preload-in-webpack-51a52358f84c](https://medium.com/webpack/link-rel-prefetch-preload-in-webpack-51a52358f84c).
|
313
|
+
|
314
|
+
You can preload your assets with the `preload_pack_asset` helper if you have Rails >= 5.2.x.
|
315
|
+
|
316
|
+
```erb
|
317
|
+
<%= preload_pack_asset 'fonts/fa-regular-400.woff2' %>
|
318
|
+
```
|
319
|
+
|
320
|
+
**Warning:** You don't want to preload the css, you want to preload the fonts and images inside the css so that fonts, css, and images can all be downloaded in parallel instead of waiting for the browser to parse the css.
|
321
|
+
|
307
322
|
### Add common chunks (deprecated in Webpack V4)
|
308
323
|
|
309
324
|
The CommonsChunkPlugin is an opt-in feature that creates a separate file (known as a chunk), consisting of common modules shared between multiple entry points. By separating common modules from bundles, the resulting chunked file can be loaded once initially, and stored in the cache for later use. This results in page speed optimizations as the browser can quickly serve the shared code from the cache, rather than being forced to load a larger bundle whenever a new page is visited.
|
data/lib/install/bin/webpack
CHANGED
data/lib/install/coffee.rb
CHANGED
@@ -6,7 +6,7 @@ copy_file "#{__dir__}/loaders/coffee.js", Rails.root.join("config/webpack/loader
|
|
6
6
|
say "Adding coffee loader to config/webpack/environment.js"
|
7
7
|
insert_into_file Rails.root.join("config/webpack/environment.js").to_s,
|
8
8
|
"const coffee = require('./loaders/coffee')\n",
|
9
|
-
after:
|
9
|
+
after: /require\(('|")@rails\/webpacker\1\);?\n/
|
10
10
|
|
11
11
|
insert_into_file Rails.root.join("config/webpack/environment.js").to_s,
|
12
12
|
"environment.loaders.prepend('coffee', coffee)\n",
|
@@ -18,7 +18,7 @@ module.exports = function(api) {
|
|
18
18
|
return {
|
19
19
|
presets: [
|
20
20
|
isTestEnv && [
|
21
|
-
|
21
|
+
'@babel/preset-env',
|
22
22
|
{
|
23
23
|
targets: {
|
24
24
|
node: 'current'
|
@@ -26,7 +26,7 @@ module.exports = function(api) {
|
|
26
26
|
}
|
27
27
|
],
|
28
28
|
(isProductionEnv || isDevelopmentEnv) && [
|
29
|
-
|
29
|
+
'@babel/preset-env',
|
30
30
|
{
|
31
31
|
forceAllTransforms: true,
|
32
32
|
useBuiltIns: 'entry',
|
@@ -37,24 +37,24 @@ module.exports = function(api) {
|
|
37
37
|
]
|
38
38
|
].filter(Boolean),
|
39
39
|
plugins: [
|
40
|
-
|
41
|
-
|
42
|
-
isTestEnv &&
|
43
|
-
|
40
|
+
'babel-plugin-macros',
|
41
|
+
'@babel/plugin-syntax-dynamic-import',
|
42
|
+
isTestEnv && 'babel-plugin-dynamic-import-node',
|
43
|
+
'@babel/plugin-transform-destructuring',
|
44
44
|
[
|
45
|
-
|
45
|
+
'@babel/plugin-proposal-class-properties',
|
46
46
|
{
|
47
47
|
loose: true
|
48
48
|
}
|
49
49
|
],
|
50
50
|
[
|
51
|
-
|
51
|
+
'@babel/plugin-proposal-object-rest-spread',
|
52
52
|
{
|
53
53
|
useBuiltIns: true
|
54
54
|
}
|
55
55
|
],
|
56
56
|
[
|
57
|
-
|
57
|
+
'@babel/plugin-transform-runtime',
|
58
58
|
{
|
59
59
|
helpers: false,
|
60
60
|
regenerator: true,
|
@@ -62,7 +62,7 @@ module.exports = function(api) {
|
|
62
62
|
}
|
63
63
|
],
|
64
64
|
[
|
65
|
-
|
65
|
+
'@babel/plugin-transform-regenerator',
|
66
66
|
{
|
67
67
|
async: false
|
68
68
|
}
|
@@ -7,7 +7,7 @@ default: &default
|
|
7
7
|
public_output_path: packs
|
8
8
|
cache_path: tmp/cache/webpacker
|
9
9
|
check_yarn_integrity: false
|
10
|
-
webpack_compile_output:
|
10
|
+
webpack_compile_output: true
|
11
11
|
|
12
12
|
# Additional paths webpack should lookup modules
|
13
13
|
# ['app/assets', 'engine/foo/app/assets']
|
@@ -69,6 +69,7 @@ development:
|
|
69
69
|
disable_host_check: true
|
70
70
|
use_local_ip: false
|
71
71
|
quiet: false
|
72
|
+
pretty: false
|
72
73
|
headers:
|
73
74
|
'Access-Control-Allow-Origin': '*'
|
74
75
|
watch_options:
|
data/lib/install/elm.rb
CHANGED
@@ -6,7 +6,7 @@ copy_file "#{__dir__}/loaders/elm.js", Rails.root.join("config/webpack/loaders/e
|
|
6
6
|
say "Adding elm loader to config/webpack/environment.js"
|
7
7
|
insert_into_file Rails.root.join("config/webpack/environment.js").to_s,
|
8
8
|
"const elm = require('./loaders/elm')\n",
|
9
|
-
after:
|
9
|
+
after: /require\(('|")@rails\/webpacker\1\);?\n/
|
10
10
|
|
11
11
|
insert_into_file Rails.root.join("config/webpack/environment.js").to_s,
|
12
12
|
"environment.loaders.prepend('elm', elm)\n",
|
data/lib/install/erb.rb
CHANGED
@@ -5,8 +5,8 @@ copy_file "#{__dir__}/loaders/erb.js", Rails.root.join("config/webpack/loaders/e
|
|
5
5
|
|
6
6
|
say "Adding erb loader to config/webpack/environment.js"
|
7
7
|
insert_into_file Rails.root.join("config/webpack/environment.js").to_s,
|
8
|
-
"const erb =
|
9
|
-
after:
|
8
|
+
"const erb = require('./loaders/erb')\n",
|
9
|
+
after: /require\(('|")@rails\/webpacker\1\);?\n/
|
10
10
|
|
11
11
|
insert_into_file Rails.root.join("config/webpack/environment.js").to_s,
|
12
12
|
"environment.loaders.prepend('erb', erb)\n",
|
@@ -38,8 +38,8 @@
|
|
38
38
|
// import 'classlist.js'; // Run `npm install --save classlist.js`.
|
39
39
|
|
40
40
|
/** Evergreen browsers require these. **/
|
41
|
-
import 'core-js/
|
42
|
-
import 'core-js/
|
41
|
+
import 'core-js/es/reflect';
|
42
|
+
import 'core-js/proposals/reflect-metadata';
|
43
43
|
|
44
44
|
|
45
45
|
/**
|
@@ -18,15 +18,17 @@ module.exports = function(api) {
|
|
18
18
|
return {
|
19
19
|
presets: [
|
20
20
|
isTestEnv && [
|
21
|
-
|
21
|
+
'@babel/preset-env',
|
22
22
|
{
|
23
23
|
targets: {
|
24
24
|
node: 'current'
|
25
|
-
}
|
26
|
-
|
25
|
+
},
|
26
|
+
modules: 'commonjs'
|
27
|
+
},
|
28
|
+
'@babel/preset-react'
|
27
29
|
],
|
28
30
|
(isProductionEnv || isDevelopmentEnv) && [
|
29
|
-
|
31
|
+
'@babel/preset-env',
|
30
32
|
{
|
31
33
|
forceAllTransforms: true,
|
32
34
|
useBuiltIns: 'entry',
|
@@ -36,7 +38,7 @@ module.exports = function(api) {
|
|
36
38
|
}
|
37
39
|
],
|
38
40
|
[
|
39
|
-
|
41
|
+
'@babel/preset-react',
|
40
42
|
{
|
41
43
|
development: isDevelopmentEnv || isTestEnv,
|
42
44
|
useBuiltIns: true
|
@@ -44,24 +46,24 @@ module.exports = function(api) {
|
|
44
46
|
]
|
45
47
|
].filter(Boolean),
|
46
48
|
plugins: [
|
47
|
-
|
48
|
-
|
49
|
-
isTestEnv &&
|
50
|
-
|
49
|
+
'babel-plugin-macros',
|
50
|
+
'@babel/plugin-syntax-dynamic-import',
|
51
|
+
isTestEnv && 'babel-plugin-dynamic-import-node',
|
52
|
+
'@babel/plugin-transform-destructuring',
|
51
53
|
[
|
52
|
-
|
54
|
+
'@babel/plugin-proposal-class-properties',
|
53
55
|
{
|
54
56
|
loose: true
|
55
57
|
}
|
56
58
|
],
|
57
59
|
[
|
58
|
-
|
60
|
+
'@babel/plugin-proposal-object-rest-spread',
|
59
61
|
{
|
60
62
|
useBuiltIns: true
|
61
63
|
}
|
62
64
|
],
|
63
65
|
[
|
64
|
-
|
66
|
+
'@babel/plugin-transform-runtime',
|
65
67
|
{
|
66
68
|
helpers: false,
|
67
69
|
regenerator: true,
|
@@ -69,13 +71,13 @@ module.exports = function(api) {
|
|
69
71
|
}
|
70
72
|
],
|
71
73
|
[
|
72
|
-
|
74
|
+
'@babel/plugin-transform-regenerator',
|
73
75
|
{
|
74
76
|
async: false
|
75
77
|
}
|
76
78
|
],
|
77
79
|
isProductionEnv && [
|
78
|
-
|
80
|
+
'babel-plugin-transform-react-remove-prop-types',
|
79
81
|
{
|
80
82
|
removeImport: true
|
81
83
|
}
|
@@ -0,0 +1,20 @@
|
|
1
|
+
/* eslint no-console: 0 */
|
2
|
+
// Run this example by adding <%= javascript_pack_tag 'hello_svelte' %> (and
|
3
|
+
// <%= stylesheet_pack_tag 'hello_svelte' %> if you have styles in your component)
|
4
|
+
// to the head of your layout file,
|
5
|
+
// like app/views/layouts/application.html.erb.
|
6
|
+
// All it does is render <div>Hello Svelte!</div> at the bottom of the page.
|
7
|
+
|
8
|
+
import App from '../app.svelte'
|
9
|
+
|
10
|
+
document.addEventListener('DOMContentLoaded', () => {
|
11
|
+
const app = new App({
|
12
|
+
target: document.body,
|
13
|
+
props: {
|
14
|
+
name: 'Svelte'
|
15
|
+
}
|
16
|
+
});
|
17
|
+
|
18
|
+
window.app = app;
|
19
|
+
})
|
20
|
+
|
data/lib/install/loaders/elm.js
CHANGED
@@ -1,18 +1,21 @@
|
|
1
1
|
const { resolve } = require('path')
|
2
2
|
|
3
3
|
const isProduction = process.env.NODE_ENV === 'production'
|
4
|
+
const isDevelopment = process.env.NODE_ENV === 'development'
|
4
5
|
const elmSource = resolve(process.cwd())
|
5
6
|
const elmBinary = `${elmSource}/node_modules/.bin/elm`
|
6
7
|
|
7
|
-
const
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
8
|
+
const options = {
|
9
|
+
cwd: elmSource,
|
10
|
+
pathToElm: elmBinary,
|
11
|
+
optimize: isProduction,
|
12
|
+
verbose: isDevelopment,
|
13
|
+
debug: isDevelopment
|
14
|
+
}
|
12
15
|
|
13
16
|
const elmWebpackLoader = {
|
14
17
|
loader: 'elm-webpack-loader',
|
15
|
-
options:
|
18
|
+
options: options
|
16
19
|
}
|
17
20
|
|
18
21
|
module.exports = {
|