I created a new rails application using:
rails new blah --webpack -T
I then added primer
yarn add primer
My import works if I do this in /assets/stylesheets/application.scss
@import "~primer/index.scss";
Primer has lots of modules, so the primer/index.scss then references the files from other modules. So even if I put the tilda in my first import, it doesn't solve the problem because in other files it has no tilda.
But the problem is that once the index.scss file loads, there are other files that stop working because they are also referencing files like:
// Core modules
@import "primer-base/index.scss";
@import "primer-box/index.scss";
@import "primer-breadcrumb/index.scss";
@import "primer-buttons/index.scss";
@import "primer-table-object/index.scss";
@import "primer-forms/index.scss";
@import "primer-layout/index.scss";
@import "primer-navigation/index.scss";
@import "primer-pagination/index.scss";
@import "primer-tooltips/index.scss";
@import "primer-truncate/index.scss";
So these imports have to be changed also. I need to solve this so I don't have to prefix with the tilda sign. My assets.rb is already including node_modules so I'm not sure what else I can do?
My /initializers/assets.rb has this:
Rails.application.config.assets.paths << Rails.root.join('node_modules')
Yet in my application.scss file I have to include the tilda sign to reference a scss file:
@import "primer/index.scss";
html {
font-size: 30px;
}
application.js file:
import "./application.scss";
console.log('Hello World from Webpacker2d');
My layout file:
<!DOCTYPE html>
<html>
<head>
<title>Blah</title>
<%= csrf_meta_tags %>
<%= csp_meta_tag %>
<%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track': 'reload' %>
<%= javascript_include_tag 'application', 'data-turbolinks-track': 'reload' %>
<%= javascript_pack_tag 'application' %>
<%= stylesheet_pack_tag 'application' %>
</head>
<body>
<%= yield %>
</body>
</html>