my project is currently using Rails 6.1, #fortawesome/fontawesome-free 5.15.3 & Heroku. My config is straightforward:
// package.json
{
"name": "web",
"dependencies": {
"#fortawesome/fontawesome-free": "^5.15.3",
...
},
...
}
// app/javascript/packs/application.js
...
Rails.start()
...
import "stylesheets/application"
import "#fortawesome/fontawesome-free/css/all"
I use FontAwesome icons as CSS classes, which I call within my .html.erb files:
<i class="fas fa-users"></i>
I use very few icons from the framework (< 20), yet Webpack seems to compile the whole framework. Everything works fine, I am just surprised how the FA framework is still compiled in all possible formats (css (the only one I need), svg, webfonts).
Here are my Heroku build logs:
Version: webpack 4.46.0
Time: 19571ms
Built at: 07/21/2021 9:10:54 PM
Asset Size Chunks Chunk Names
css/application-e87f29dc.css 72.8 KiB 0 [emitted] [immutable] application
css/application-e87f29dc.css.br 13.7 KiB [emitted]
css/application-e87f29dc.css.gz 16.4 KiB [emitted]
js/application-5ac2d3a4589f0bac8765.js 128 KiB 0 [emitted] [immutable] application
js/application-5ac2d3a4589f0bac8765.js.br 25.4 KiB [emitted]
js/application-5ac2d3a4589f0bac8765.js.gz 29.3 KiB [emitted]
js/application-5ac2d3a4589f0bac8765.js.map 370 KiB 0 [emitted] [dev] application
js/application-5ac2d3a4589f0bac8765.js.map.br 75.2 KiB [emitted]
js/application-5ac2d3a4589f0bac8765.js.map.gz 86.9 KiB [emitted]
manifest.json 1.82 KiB [emitted]
manifest.json.br 348 bytes [emitted]
manifest.json.gz 403 bytes [emitted]
media/webfonts/fa-brands-400-216edb96.svg 730 KiB [emitted] [big]
media/webfonts/fa-brands-400-216edb96.svg.br 218 KiB [emitted]
media/webfonts/fa-brands-400-216edb96.svg.gz 249 KiB [emitted] [big]
media/webfonts/fa-brands-400-329a95a9.woff 87.9 KiB [emitted]
media/webfonts/fa-brands-400-89a52ae1.eot 131 KiB [emitted]
media/webfonts/fa-brands-400-89a52ae1.eot.br 81.9 KiB [emitted]
media/webfonts/fa-brands-400-89a52ae1.eot.gz 88.6 KiB [emitted]
media/webfonts/fa-brands-400-9e138496.ttf 131 KiB [emitted]
media/webfonts/fa-brands-400-9e138496.ttf.br 81.9 KiB [emitted]
media/webfonts/fa-brands-400-9e138496.ttf.gz 88.5 KiB [emitted]
media/webfonts/fa-brands-400-c1210e5e.woff2 75 KiB [emitted]
media/webfonts/fa-regular-400-1017bce8.ttf 32.9 KiB [emitted]
media/webfonts/fa-regular-400-1017bce8.ttf.br 15 KiB [emitted]
media/webfonts/fa-regular-400-1017bce8.ttf.gz 15.9 KiB [emitted]
media/webfonts/fa-regular-400-19e27d34.svg 141 KiB [emitted]
media/webfonts/fa-regular-400-19e27d34.svg.br 30.3 KiB [emitted]
media/webfonts/fa-regular-400-19e27d34.svg.gz 36.3 KiB [emitted]
media/webfonts/fa-regular-400-36722648.woff 15.9 KiB [emitted]
media/webfonts/fa-regular-400-4079ae2d.eot 33.2 KiB [emitted]
media/webfonts/fa-regular-400-4079ae2d.eot.br 15.1 KiB [emitted]
media/webfonts/fa-regular-400-4079ae2d.eot.gz 15.9 KiB [emitted]
media/webfonts/fa-regular-400-68c5af1f.woff2 13 KiB [emitted]
media/webfonts/fa-solid-900-07c3313b.ttf 198 KiB [emitted]
media/webfonts/fa-solid-900-07c3313b.ttf.br 90.3 KiB [emitted]
media/webfonts/fa-solid-900-07c3313b.ttf.gz 100 KiB [emitted]
media/webfonts/fa-solid-900-13de59f1.svg 897 KiB [emitted] [big]
media/webfonts/fa-solid-900-13de59f1.svg.br 199 KiB [emitted]
media/webfonts/fa-solid-900-13de59f1.svg.gz 250 KiB [emitted] [big]
media/webfonts/fa-solid-900-ada6e6df.woff2 76.4 KiB [emitted]
media/webfonts/fa-solid-900-c6ec0800.woff 99.3 KiB [emitted]
media/webfonts/fa-solid-900-efbd5d20.eot 198 KiB [emitted]
media/webfonts/fa-solid-900-efbd5d20.eot.br 90.4 KiB [emitted]
media/webfonts/fa-solid-900-efbd5d20.eot.gz 100 KiB [emitted]
Entrypoint application = css/application-e87f29dc.css js/application-5ac2d3a4589f0bac8765.js js/application-5ac2d3a4589f0bac8765.js.map
[0] ./node_modules/stimulus/index.js + 38 modules 77.4 KiB {0} [built]
| 39 modules
[2] (webpack)/buildin/module.js 552 bytes {0} [built]
[5] ./app/javascript/stylesheets/application.scss 39 bytes {0} [built]
[7] ./app/javascript/controllers sync _controller\.js$ 243 bytes {0} [built]
[8] ./app/javascript/controllers/forecasts_controller.js 3.28 KiB {0} [optional] [built]
[9] ./app/javascript/controllers/hello_controller.js 2.67 KiB {0} [optional] [built]
[10] ./app/javascript/controllers/search_controller.js 4.37 KiB {0} [optional] [built]
[11] ./app/javascript/packs/application.js + 4 modules 16.7 KiB {0} [built]
| ./app/javascript/packs/application.js 585 bytes [built]
| ./app/javascript/controllers/index.js 742 bytes [built]
| + 3 hidden modules
+ 6 hidden modules
WARNING in asset size limit: The following asset(s) exceed the recommended size limit (244 KiB).
This can impact web performance.
Assets:
media/webfonts/fa-solid-900-13de59f1.svg (897 KiB)
media/webfonts/fa-brands-400-216edb96.svg (730 KiB)
media/webfonts/fa-solid-900-13de59f1.svg.gz (250 KiB)
media/webfonts/fa-brands-400-216edb96.svg.gz (249 KiB)
WARNING in webpack performance recommendations:
You can limit the size of your bundles by using import() or require.ensure to lazy load some parts of your application.
For more info visit https://webpack.js.org/guides/code-splitting/
Child mini-css-extract-plugin node_modules/css-loader/dist/cjs.js??ref--5-1!node_modules/postcss-loader/src/index.js??ref--5-2!node_modules/#fortawesome/fontawesome-free/css/all.css:
Entrypoint mini-css-extract-plugin = *
18 modules
Child mini-css-extract-plugin node_modules/css-loader/dist/cjs.js??ref--6-1!node_modules/postcss-loader/src/index.js??ref--6-2!node_modules/sass-loader/dist/cjs.js??ref--6-3!app/javascript/stylesheets/application.scss:
Entrypoint mini-css-extract-plugin = *
[0] ./node_modules/css-loader/dist/cjs.js??ref--6-1!./node_modules/postcss-loader/src??ref--6-2!./node_modules/sass-loader/dist/cjs.js??ref--6-3!./app/javascript/stylesheets/application.scss 43.7 KiB {0} [built]
+ 1 hidden module
Asset precompilation completed (58.34s)
Should I worry about the size of these files like Webpack warns me? Is there any way to purge FontAwesome (like I do with Tailwind) so that only the used icons are compiled? Am I missing something about how Webpack works?
you could import only icons you wanna use
import { library } from "#fortawesome/fontawesome-svg-core";
import {
faFacebookSquare,
faGooglePlusSquare
} from "#fortawesome/free-brands-svg-icons";
library.add(faFacebookSquare, faGooglePlusSquare);
Note that if those icons do not show, then you maybe need dom helper
import { library, dom } from "#fortawesome/fontawesome-svg-core";
import {
faFacebookSquare,
faGooglePlusSquare
} from "#fortawesome/free-brands-svg-icons";
library.add(faFacebookSquare, faGooglePlusSquare);
// Kicks off the process of finding <i> tags and replacing with <svg>
dom.watch();
Related
I have a problem. In my Rails application I wanted to use TypeScript using webpacker. To install the TypeScript implementation I did the following:
I ran:
rails webpacker:install:typescript
Then edited the tsconfig.json by changing the module setting to "es6" and added "strict": true
Then I ran: rails webpacker:compile. After that I can see in the output that it compiled the following typescript files:
Compiling...
Compiled all packs in /app/public/packs
Hash: 0aff66e45830e2859a39
Version: webpack 4.46.0
Time: 1266ms
Built at: 12/07/2022 10:05:05 AM
Asset Size Chunks Chunk Names
js/application-ee3dc001e34e3c7c97e6.js 1.02 KiB 0 [emitted] [immutable] application
js/application-ee3dc001e34e3c7c97e6.js.br 466 bytes [emitted]
js/application-ee3dc001e34e3c7c97e6.js.gz 537 bytes [emitted]
js/application-ee3dc001e34e3c7c97e6.js.map 5.54 KiB 0 [emitted] [dev] application
js/application-ee3dc001e34e3c7c97e6.js.map.br 1.92 KiB [emitted]
js/application-ee3dc001e34e3c7c97e6.js.map.gz 2.2 KiB [emitted]
js/hello_typescript-db05426ac67e3cfab42d.js 1.02 KiB 1 [emitted] [immutable] hello_typescript
js/hello_typescript-db05426ac67e3cfab42d.js.br 487 bytes [emitted]
js/hello_typescript-db05426ac67e3cfab42d.js.gz 539 bytes [emitted]
js/hello_typescript-db05426ac67e3cfab42d.js.map 4.91 KiB 1 [emitted] [dev] hello_typescript
js/hello_typescript-db05426ac67e3cfab42d.js.map.br 1.68 KiB [emitted]
js/hello_typescript-db05426ac67e3cfab42d.js.map.gz 1.9 KiB [emitted]
manifest.json 738 bytes [emitted]
manifest.json.br 172 bytes [emitted]
manifest.json.gz 205 bytes [emitted]
Entrypoint application = js/application-ee3dc001e34e3c7c97e6.js js/application-ee3dc001e34e3c7c97e6.js.map
Entrypoint hello_typescript = js/hello_typescript-db05426ac67e3cfab42d.js js/hello_typescript-db05426ac67e3cfab42d.js.map
[0] ./app/javascript/packs/application.ts 845 bytes {0} [built]
[1] ./app/javascript/packs/hello_typescript.ts 200 bytes {1} [built]
In my application.html.erb I have the following default imports in the head:
<%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track': 'reload' %>
<%= javascript_pack_tag 'application', 'data-turbolinks-track': 'reload' %>
<%= javascript_include_tag "application", "data-turbo-track": "reload", defer: true %>
But this results in an error on the 3th line with:
The asset "application.js" is not present in the asset pipeline.
I also tried renaming the app/javascript/packs/application.ts file to a .js file, but that results in the same error. The other thing I tried was adding a application.js file to app/javascript, to see if the error is caused by the fact that it is now placed in a packs foler, but also no luck with that
What am I missing here?
Vaadin suddenly stops to build my library with the following error. I already did the Vaadin dance (and a lot of more stuff) but I'm running out of ideas now. I try to build the library for production (but it also fails for dev).
I'm using Vaadin Flow. The issue tracker on Github redirected here for general community help - so I hope anyone has an idea how to solve this problem or what else I can try.
> Task vaadinBuildFrontend FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task 'vaadinBuildFrontend'.
> Webpack process exited with non-zero exit code.
Stderr: 'Hash: e1a6ace26ca6df86c87b
Version: webpack 4.46.0
Time: 6054ms
Built at: 12/22/2021 7:13:38 PM
Asset Size Chunks Chunk Names
VAADIN/build/vaadin-1-8595bda5c7958e210407.cache.js 894 KiB 1 [immutable]
VAADIN/build/vaadin-2-d5ce16eeb5d943cfe059.cache.js 284 KiB 2 [immutable]
VAADIN/build/vaadin-3-7d2fe309de5248ed4c09.cache.js 48.7 KiB 3 [immutable]
VAADIN/build/vaadin-4-2758512dfda3ea8392cc.cache.js 1.05 KiB 4 [immutable]
Entrypoint bundle =
[0] ./generated/vaadin.ts + 2 modules 91.2 KiB {0} [built]
| ./generated/vaadin.ts 18 bytes [built]
| ./generated/index.ts 337 bytes [built]
| ../node_modules/.pnpm/#vaadin/router#1.7.4/node_modules/#vaadin/router/dist/vaadin-router.js 90.9 KiB [built]
[1] ../node_modules/.pnpm/#vaadin/vaadin-themable-mixin#22.0.1/node_modules/#vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js 7.07 KiB {2} [built]
[3] ../node_modules/.pnpm/lit#2.0.0/node_modules/lit/index.js + 3 modules 8.83 KiB {2} [built]
| ../node_modules/.pnpm/lit#2.0.0/node_modules/lit/index.js 122 bytes [built]
| ../node_modules/.pnpm/#lit/reactive-element#1.0.2/node_modules/#lit/reactive-element/reactive-element.js 5.89 KiB [built]
| ../node_modules/.pnpm/lit-element#3.0.2/node_modules/lit-element/lit-element.js 1.35 KiB [built]
| ../node_modules/.pnpm/#lit/reactive-element#1.0.2/node_modules/#lit/reactive-element/css-tag.js 1.46 KiB [built]
[4] ../node_modules/.pnpm/#vaadin/vaadin-lumo-styles#22.0.1/node_modules/#vaadin/vaadin-lumo-styles/spacing.js 1.42 KiB {2} [built]
[5] ../node_modules/.pnpm/#vaadin/vaadin-lumo-styles#22.0.1/node_modules/#vaadin/vaadin-lumo-styles/color.js 6.82 KiB {2} [built]
[6] ../node_modules/.pnpm/#vaadin/vaadin-lumo-styles#22.0.1/node_modules/#vaadin/vaadin-lumo-styles/style.js 1.38 KiB {2} [built]
[8] ../node_modules/.pnpm/#vaadin/vaadin-lumo-styles#22.0.1/node_modules/#vaadin/vaadin-lumo-styles/sizing.js 829 bytes {2} [built]
[9] ../node_modules/.pnpm/#vaadin/vaadin-lumo-styles#22.0.1/node_modules/#vaadin/vaadin-lumo-styles/typography.js 2.99 KiB {2} [built]
[27] ../node_modules/.pnpm/#vaadin/vaadin-lumo-styles#22.0.1/node_modules/#vaadin/vaadin-lumo-styles/version.js 313 bytes {2} [built]
[43] ../node_modules/.pnpm/#vaadin/button#22.0.1/node_modules/#vaadin/button/theme/lumo/vaadin-button.js 73 bytes {1} [built]
[80] ../node_modules/.pnpm/#vaadin/vaadin-lumo-styles#22.0.1/node_modules/#vaadin/vaadin-lumo-styles/icons.js + 2 modules 31.5 KiB {2} [built]
| ../node_modules/.pnpm/#vaadin/vaadin-lumo-styles#22.0.1/node_modules/#vaadin/vaadin-lumo-styles/icons.js 276 bytes [built]
| ../node_modules/.pnpm/#vaadin/vaadin-lumo-styles#22.0.1/node_modules/#vaadin/vaadin-lumo-styles/iconset.js 15.5 KiB [built]
| ../node_modules/.pnpm/#vaadin/vaadin-lumo-styles#22.0.1/node_modules/#vaadin/vaadin-lumo-styles/vaadin-iconset.js 15.7 KiB [built]
[188] ../node_modules/.pnpm/#vaadin/common-frontend#0.0.17_lit#2.0.0/node_modules/#vaadin/common-frontend/ConnectionIndicator.js + 14 modules 35.9 KiB {2} [built]
| ../node_modules/.pnpm/#vaadin/common-frontend#0.0.17_lit#2.0.0/node_modules/#vaadin/common-frontend/ConnectionIndicator.js 14.3 KiB [built]
| ../node_modules/.pnpm/tslib#2.3.1/node_modules/tslib/tslib.es6.js 11.5 KiB [built]
| ../node_modules/.pnpm/lit#2.0.0/node_modules/lit/decorators.js 525 bytes [built]
| ../node_modules/.pnpm/lit#2.0.0/node_modules/lit/directives/class-map.js 85 bytes [built]
| ../node_modules/.pnpm/#vaadin/common-frontend#0.0.17_lit#2.0.0/node_modules/#vaadin/common-frontend/ConnectionState.js 4.36 KiB [built]
| ../node_modules/.pnpm/#lit/reactive-element#1.0.2/node_modules/#lit/reactive-element/decorators/custom-element.js 364 bytes [built]
| ../node_modules/.pnpm/#lit/reactive-element#1.0.2/node_modules/#lit/reactive-element/decorators/property.js 572 bytes [built]
| ../node_modules/.pnpm/#lit/reactive-element#1.0.2/node_modules/#lit/reactive-element/decorators/state.js 225 bytes [built]
| ../node_modules/.pnpm/#lit/reactive-element#1.0.2/node_modules/#lit/reactive-element/decorators/event-options.js 280 bytes [built]
| ../node_modules/.pnpm/#lit/reactive-element#1.0.2/node_modules/#lit/reactive-element/decorators/query.js 612 bytes [built]
| ../node_modules/.pnpm/#lit/reactive-element#1.0.2/node_modules/#lit/reactive-element/decorators/query-all.js 388 bytes [built]
| ../node_modules/.pnpm/#lit/reactive-element#1.0.2/node_modules/#lit/reactive-element/decorators/query-async.js 392 bytes [built]
| ../node_modules/.pnpm/#lit/reactive-element#1.0.2/node_modules/#lit/reactive-element/decorators/query-assigned-nodes.js 603 bytes [built]
| ../node_modules/.pnpm/lit-html#2.0.2/node_modules/lit-html/directives/class-map.js 1.1 KiB [built]
| ../node_modules/.pnpm/#lit/reactive-element#1.0.2/node_modules/#lit/reactive-element/decorators/base.js 666 bytes [built]
[217] ../node_modules/.pnpm/#vaadin/polymer-legacy-adapter#22.0.1/node_modules/#vaadin/polymer-legacy-adapter/style-modules.js + 1 modules 4.38 KiB {2} [built]
| ../node_modules/.pnpm/#vaadin/polymer-legacy-adapter#22.0.1/node_modules/#vaadin/polymer-legacy-adapter/style-modules.js 191 bytes [built]
| ../node_modules/.pnpm/#vaadin/polymer-legacy-adapter#22.0.1/node_modules/#vaadin/polymer-legacy-adapter/src/style-modules.js 4.17 KiB [built]
[222] ../build/frontend/generated-flow-imports-fallback.js + 56 modules 104 KiB {3} [built]
| ../build/frontend/generated-flow-imports-fallback.js 9.98 KiB [built]
| ./basic/variables.css 943 bytes [built]
| ./images/cropper/cropper.css 778 bytes [built]
| ./basic/spacer.css 116 bytes [built]
| ./tab-box/tab-box.css 458 bytes [built]
| ./text/text-area.css 103 bytes [built]
| ./buttons/internal-button.css 104 bytes [built]
| ./layouts/br-app-layout.css 206 bytes [built]
| ./buttons/flat-icon-button.css 242 bytes [built]
| ./modal/raven-modal.css 219 bytes [built]
| ./headings/headings.css 60 bytes [built]
| ./layouts/br-horizontal-layout.css 150 bytes [built]
| ./text/text-line-with-icon.css 182 bytes [built]
| ./input/br-inline-edit.css 159 bytes [built]
| ./buttons/action-button.css 890 bytes [built]
| + 42 hidden modules
[223] ../build/frontend/generated-flow-imports.js + 1 modules 1.72 KiB {4} [built]
| ../build/frontend/generated-flow-imports.js 1.41 KiB [built]
| ../build/flow-frontend/lumo-includes.ts 276 bytes [built]
+ 209 hidden modules
ERROR in ./generated/index.ts
Module not found: Error: Can't resolve '#vaadin/flow-frontend/Flow' in '/XXX/frontend/generated'
# ./generated/index.ts 2:0-50 3:33-37
# ./generated/vaadin.ts
ERROR in chunk bundle [entry]
VAADIN/build/vaadin-bundle-ca5b59ddaf6cebb1e7aa.cache.js
/XXX/node_modules/.pnpm/esbuild-loader#2.15.1_webpack#4.46.0/node_modules/esbuild-loader/dist/index.js??ref--4!/XXX/frontend/generated/vaadin.ts a8f7ce42c2f8c5128bbf70605fdcb37b
Unexpected token (4:33)
|
|
| const { serverSideRoutes } = new !(function webpackMissingModule() { var e = new Error("Cannot find module '#vaadin/flow-frontend/Flow'"); e.code = 'MODULE_NOT_FOUND'; throw e; }())({
| imports: () => Promise.all(/* import() */[__webpack_require__.e(2), __webpack_require__.e(4)]).then(__webpack_require__.bind(null, 223))
| });
ERROR in frontend/generated/index.ts:17:22
TS2307: Cannot find module '#vaadin/flow-frontend/Flow' or its corresponding type declarations.
15 |
16 | // import Flow module to enable navigation to Vaadin server-side views
> 17 | import { Flow } from '#vaadin/flow-frontend/Flow';
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
18 |
19 | const { serverSideRoutes } = new Flow({
20 | imports: () => import('../../build/frontend/generated-flow-imports')
Child HtmlWebpackCompiler:
Asset Size Chunks Chunk Names
__child-HtmlWebpackPlugin_0 4.4 KiB 0 HtmlWebpackPlugin_0
Entrypoint HtmlWebpackPlugin_0 = __child-HtmlWebpackPlugin_0
[0] ../node_modules/.pnpm/html-webpack-plugin#4.5.1_webpack#4.46.0/node_modules/html-webpack-plugin/lib/loader.js!./index.html 830 bytes {0} [built]
<i> [build-status] 3 errors and 0 warnings were reported.
<i> [build-status] : Failed to compile.
'
// Edit 1
I already tried all of this (in this order):
rm -rf ~/.pnpm-store ~/.vaadin
rm -rf package.json pnpm-lock.json pnpmfile.json tsconfig.json webpack.config.js webpack.generated.js .npmrc frontend/generated/ frontend/index.html build/ target/ node_modules pnpm-lock.yaml pnpmfile.js types.d.ts
./gradlew vaadinClean && ./gradlew vaadinPrepareFrontend && ./gradlew vaadinBuildFrontend
I had the same problem migrating from V21 to V22. I fixed it by deleting the target folder (and generated files in the root folder like tsconfig etc) and rebuilding again. Worked perfectly afterwards with no further problems. My suspicion was something stayed in the target folder from V21 and confused the build.
I found the solution by rebuilding step by step the production and testing where it failed.
TL;DR: include dependency com.vaadin:flow-client if you don't use com.vaadin:vaadin-core
As I stated, I try to build a Vaadin library (to share components across different nodes). Therefor, I didn't include the dependency com.vaadin:vaadin-core but the dependencies I actually needed (also to avoid version conflicts of transitive dependencies).
For some reason (probably due to upgrading the Vaadin version), I now also need the dependency com.vaadin:flow-client. Without this specific dependency the above mentioned error can be reproduced.
I created a brand new Rails app with Ruby 2.7.2 and Ruby on Rails 6.1.3:
rails new rails6
Then I installed the CoffeeScript compiler using the Rails command:
rails webpacker:install:coffee
But when i started the webpack-dev-server, he was unable to compile correctly:
Asset Size Chunks Chunk Names
js/application-30c16ea0138c526e20f5.js 515 KiB application [emitted] [immutable] application
js/application-30c16ea0138c526e20f5.js.map 579 KiB application [emitted] [dev] application
js/hello_coffee-5eba0c58c2666f949e88.js 395 KiB hello_coffee [emitted] [immutable] hello_coffee
js/hello_coffee-5eba0c58c2666f949e88.js.map 444 KiB hello_coffee [emitted] [dev] hello_coffee
manifest.json 710 bytes [emitted]
ERROR in ./app/javascript/packs/hello_coffee.coffee
Module build failed (from ./node_modules/coffee-loader/dist/cjs.js):
TypeError: this.getOptions is not a function
at Object.loader (/Users/iwan/dev/rails/rails6/node_modules/coffee-loader/dist/index.js:21:24)
ℹ 「wdm」: Failed to compile.
How to fix this issue?
I found that downgrading coffee-loader to the version 1.0.1 removed the error.
Edit package.json and change the version from
"coffee-loader": "^2.0.0",
to
"coffee-loader": "1.0.1",
Then run yarn install --check-files to apply the change.
Happy days!
I bumped webpacker from 4.x to 5.2.1 and started getting this warning:
The resolved_paths option has been deprecated. Use additional_paths instead.
This seems straightforward enough, my config/webpacker.yml was almost unmodified:
# Additional paths webpack should lookup modules
# ['app/assets', 'engine/foo/app/assets']
resolved_paths: [
'app/assets',
]
But doing a simple s/resolved_paths/additional_paths/ there doesn't work:
[Webpacker] Compiling...
[Webpacker] Compilation failed:
Hash: 7448f36a43523a84e146
Version: webpack 4.44.1
Time: 5803ms
Built at: 10/15/2020 11:57:06 AM
Asset Size Chunks Chunk Names
js/application-a019b363e4513fe092e6.js 3.02 MiB application [emitted] [immutable] application
js/application-a019b363e4513fe092e6.js.map 3.03 MiB application [emitted] [dev] application
js/hello_react-40e806bdb6de496532d8.js 1.05 MiB hello_react [emitted] [immutable] hello_react
js/hello_react-40e806bdb6de496532d8.js.map 1.21 MiB hello_react [emitted] [dev] hello_react
js/server_rendering-9cd9dcc6e1cebb2a8063.js 2.25 MiB server_rendering [emitted] [immutable] server_rendering
js/server_rendering-9cd9dcc6e1cebb2a8063.js.map 2.44 MiB server_rendering [emitted] [dev] server_rendering
manifest.json 1.05 KiB [emitted]
Entrypoint application = js/application-a019b363e4513fe092e6.js js/application-a019b363e4513fe092e6.js.map
Entrypoint hello_react = js/hello_react-40e806bdb6de496532d8.js js/hello_react-40e806bdb6de496532d8.js.map
Entrypoint server_rendering = js/server_rendering-9cd9dcc6e1cebb2a8063.js js/server_rendering-9cd9dcc6e1cebb2a8063.js.map
[./app/javascript/channels sync recursive _channel\.js$] ./app/javascript/channels sync _channel\.js$ 160 bytes {application} [built]
[./app/javascript/channels/index.js] 211 bytes {application} [built]
[./app/javascript/components sync recursive ^\.\/.*$] ./app/javascript/components sync ^\.\/.*$ 2.42 KiB {application} {server_rendering} [built]
[./app/javascript/packs/application.js] 10.3 KiB {application} [built]
[./app/javascript/packs/hello_react.jsx] 1.05 KiB {hello_react} [built]
[./app/javascript/packs/server_rendering.js] 301 bytes {server_rendering} [built]
[./node_modules/webpack/buildin/amd-options.js] (webpack)/buildin/amd-options.js 80 bytes {application} {server_rendering} [built]
[./node_modules/webpack/buildin/global.js] (webpack)/buildin/global.js 905 bytes {application} {server_rendering} [built]
[./node_modules/webpack/buildin/module.js] (webpack)/buildin/module.js 552 bytes {application} {server_rendering} [built]
+ 474 hidden modules
ERROR in ./app/javascript/components/menu/MenuComponent.jsx
Module not found: Error: Can't resolve 'images/ellipsis-v.svg' in '/home/me/app/javascript/components/menu'
So obviously additional_paths isn't just a drop-in replacement, even though the docs suggest it should be.
Before I jump into the source to try to understand what's happening here, anyone got a quick fix?
The error is logged in the web browser's console, and it comes from the npm package. You need to upgrade both: the webpacker gem and #rails/webpacker npm package.
I am trying to use Vuelidate in production with Webpacker for my Rails app.
Usually I just need to run the following commands for my packages.json to get built and deployed into my app:
RAILS_ENV=production bundle exec rake assets:clobber
RAILS_ENV=production bundle exec rake assets:clean
RAILS_ENV=production bundle exec rake assets:precompile
but this isn't working in prod since I added Vuelidate (works fine in dev).
Using /home/my_user/my_app/config/webpacker.yml file for setting up webpack paths
Compiling…
Compilation failed:
Hash: a535894e7898c0a336a3
Version: webpack 3.5.6
Time: 13838ms
Asset Size Chunks Chunk Names
app-36e1d2de960efd5bf847.js.map 17.4 kB 2 [emitted] app
dashboard-9cadea07287686e15eed.js 99 kB 0 [emitted] dashboard
app-36e1d2de960efd5bf847.js 1.65 kB 2 [emitted] app
app-4758d50be4328c1ed27fc08a09d9dae2.css 119 bytes 2 [emitted] app
dashboard-9cadea07287686e15eed.js.map 808 kB 0 [emitted] dashboard
application-06c4c55e7d8c8e2ea0de.js.map 703 kB 1 [emitted] application
application-06c4c55e7d8c8e2ea0de.js 83.9 kB 1 [emitted] application
app-4758d50be4328c1ed27fc08a09d9dae2.css.map 117 bytes 2 [emitted] app
app-36e1d2de960efd5bf847.js.gz 843 bytes [emitted]
application-06c4c55e7d8c8e2ea0de.js.gz 30.5 kB [emitted]
dashboard-9cadea07287686e15eed.js.gz 35.4 kB [emitted]
manifest.json 518 bytes [emitted]
[1] (webpack)/buildin/global.js 509 bytes {0} {1} [built]
[2] ./app/javascript/packs/app.vue + 2 modules 1.65 kB {2} [built]
[3] ./node_modules/extract-text-webpack-plugin/dist/loader.js?{"omit":1,"remove":true}!./node_modules/vue-style-loader!./node_modules/css-loader?minimize!./node_modules/vue-loader/lib/style-compiler?{"vue":true,"id":"data-v-18f420a0","scoped":true,"hasInlineConfig":false}!./node_modules/vue-loader/lib/selector.js?type=styles&index=0!./app/javascript/packs/app.vue 41 bytes {2} [built]
[5] ./app/javascript/packs/application.js 1.92 kB {1} [built]
[6] ./app/javascript/packs/dashboard.js + 1 modules 45.1 kB {0} [built]
[8] ./node_modules/css-loader?minimize!./node_modules/vue-loader/lib/style-compiler?{"vue":true,"id":"data-v-18f420a0","scoped":true,"hasInlineConfig":false}!./node_modules/vue-loader/lib/selector.js?type=styles&index=0!./app/javascript/packs/app.vue 220 bytes [built]
+ 6 hidden modules
ERROR in ./app/javascript/packs/application.js
Module not found: Error: Can't resolve 'vuelidate' in '/home/my_user/my_app/app/javascript/packs'
# ./app/javascript/packs/application.js 13:0-34
ERROR in ./app/javascript/packs/dashboard.js
Module not found: Error: Can't resolve 'vuelidate' in '/home/my_user/my_app/app/javascript/packs'
# ./app/javascript/packs/dashboard.js 35:0-34
ERROR in ./app/javascript/packs/application.js
Module not found: Error: Can't resolve 'vuelidate/lib/validators' in '/home/my_user/my_app/app/javascript/packs'
# ./app/javascript/packs/application.js 14:0-59
ERROR in ./app/javascript/packs/dashboard.js
Module not found: Error: Can't resolve 'vuelidate/lib/validators' in '/home/my_user/my_app/app/javascript/packs'
# ./app/javascript/packs/dashboard.js 36:0-72
Child extract-text-webpack-plugin node_modules/extract-text-webpack-plugin/dist node_modules/css-loader/index.js?minimize!node_modules/vue-loader/lib/style-compiler/index.js?{"vue":true,"id":"data-v-18f420a0","scoped":true,"hasInlineConfig":false}!node_modules/vue-loader/lib/selector.js?type=styles&index=0!app/javascript/packs/app.vue:
[0] ./node_modules/css-loader?minimize!./node_modules/vue-loader/lib/style-compiler?{"vue":true,"id":"data-v-18f420a0","scoped":true,"hasInlineConfig":false}!./node_modules/vue-loader/lib/selector.js?type=styles&index=0!./app/javascript/packs/app.vue 220 bytes {0} [built]
+ 1 hidden module
here is my package.json file:
{
"license": "UNLICENSED",
"dependencies": {
"#rails/webpacker": "^3.0.1",
"vue": "^2.4.3",
"vue-loader": "^13.0.4",
"vue-resource": "^1.3.4",
"vue-template-compiler": "^2.4.3",
"vuelidate": "^0.5.0"
},
"devDependencies": {
"webpack-dev-server": "^2.8.1"
}
}
I'm guessing the pack isn't being properly installed to /home/my_user/my_app/app/javascript/packs. Any idea how I'd fix this?
Thanks in advance!