[RUBY] Addicted to the webpacker that comes standard with Rails 6

Origin

"Hmm? Shall we see it here?"

So, I was embarrassed to get hooked without noticing it, so I made a memorandum.

There is a lot of information on stories such as npm and yarn, so go there.

Target of build with webpacker of target system

:application.html.erb


<%= stylesheet_pack_tag 'application' %>
<%= javascript_pack_tag 'application', 'data-turbolinks-track': 'reload' %>

Since it is, both js and css are build targets.

File structure (only necessary parts)

app/
└ javascript/
  └ packs/
  | └ application.js
  └ stylesheets/
    └ application.css
    └ custom.min.css

application.js


~~abridgement~~
import "../stylesheets/application";

application.css


@import "~bootstrap/scss/bootstrap";
@import "./custom.min";

Hmmmm.

$ bin/webpack
~~abridgement~~
ERROR in ./app/javascript/stylesheets/application.css
Module build failed (from ./node_modules/mini-css-extract-plugin/dist/loader.js):
ModuleBuildError: Module build failed (from ./node_modules/postcss-loader/src/index.js):
Error: Failed to find '~bootstrap/scss/bootstrap'
~~abridgement~~

I checked the file structure including this area, but there was no problem.

I checked the error again. .. ..

ERROR in ./app/javascript/stylesheets/application.css

application.css!!

$ mv app/javascript/stylesheets/application.css app/javascript/stylesheets/application.scss

$ bin/webpack

Successful build. Tohoho. ..

Conclusion

Be careful with the extension.

Recommended Posts

Addicted to the webpacker that comes standard with Rails 6
Try to summarize the common layout with rails
[Rails] I want to load CSS with webpacker
I was addicted to setting default_url_options with Rails devise introduction
[With back tricks] How to introduce React to the simplest Rails
What I was addicted to with the Redmine REST API
How to make an application with ruby on rails (assuming that the environment has been built)
Super beginner builds Rails6 + Postgresql environment with Docker to the end
[Rails] How to introduce kaminari with Slim and change the design
I tried to implement the image preview function with Rails / jQuery
What I was addicted to when implementing google authentication with rails
About the matter that I was addicted to how to use hashmap
Connect to Rails server with iPhone
How to get along with Rails
Introducing React to Rails with react-rails
A story that I was addicted to twice with the automatic startup setting of Tomcat 8 on CentOS 8
A memo that was soberly addicted to the request of multipart / form-data
How to interact with a server that does not crash the app
How to decorate the radio button of rails6 form_with (helper) with CSS
[Rails] I was addicted to the nginx settings when using Action Cable.
Problems I was addicted to when building the digdag environment with docker
[Rails] The 12 functions that beginners have added to the problem-solving portfolio are these!
Recorded because I was addicted to the standard input of the Scanner class
Launching the production environment with docker + rails (ver5.2) and errors that occurred
[Rails] How to get the user information currently logged in with devise
[CircleCI] I was addicted to the automatic test of CircleCI (rails + mysql) [Memo]
How to compare only the time with Rails (from what time to what time, something like)
I was addicted to unit testing with the buffer operator in RxJava
How to display the text entered in text_area in Rails with line breaks
ActiveRecord prints the SQL query that is actually issued to standard output
I want to introduce the committee with Rails without getting too dirty
[Rails] How to apply the CSS used in the main app with Administrate
[Rails] How to use rails console with docker
[Rails] How to use the map method
Prepare the format environment with "Rails" (VScode)
I was addicted to the Spring-Batch test
Check the processing contents with [rails] binding.pry
[Java] Color the standard output to the terminal
The process of introducing Vuetify to Rails
How to build Rails 6 environment with Docker
[Rails] How to read the XML file uploaded from the screen with Hash type
[Rails6] How to connect the posting function generated by Scaffold with the user function generated by devise
[Rails] How to register multiple records in the intermediate table with many-to-many association
How to resolve errors that occur in the "Ruby on Rails" integration test
[Rails] How to operate the helper method used in the main application with Administrate
[Rails] When transitioning to a page with link_to, move to the specified location on the page
How to get the date from the JavaScript Date type that C # developers are addicted to
How to deal with the error yaml.scanner.ScannerError: while scanning for the next token that appeared in Rails environment construction with Docker
I rewrote the Rails tutorial test with RSpec
Print forms directly to the printer with JasperReports
[Rails] Button to return to the top of the page
Downgrade an existing app created with rails 5.2.4 to 5.1.6
The road to Japaneseizing Rails devise error messages
[Rails] rails new to create a database with PostgreSQL
[Rails] I tried to raise the Rails version from 5.0 to 5.2
Assignment to multiple variables with the ternary operator
I tried to organize the session in Rails
Publish the app made with ruby on rails
[Swift] How to link the app with Firebase
The code I used to connect Rails 3 to PostgreSQL 10
I was addicted to doing onActivityResult () with DialogFragment