-
Notifications
You must be signed in to change notification settings - Fork 97
Importing 3rd party css files from the node_modules folder #92
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Turns out my sass implementation couldn't handle the 3rd party css files. I managed to find scss versions for most of these, so it now works. Not sure what the reccomended route is if you need to import a 3rd party css file though |
@GregSmith92 What version of Yarn are you using? I'm trying to move from Yarn 1 to Yarn 3. Everything is fine except when I push to Github. I'm using Github Actions, and I'm getting
This only happens in the CI, despite the fact that it's using the same setup locally for assets. I've got the node modules in my assets.rb as well. Edit: It looks like the 'plug and play' setup for Yarn is the culprit. Adding
to the |
I have the same problem, but with the solution that @Petercopter proposed, adding to the .yarnrc.yml file that is in the root (/home/user) helped me to solve the problem, however, I do not understand why the file has not configured that line of code. nodeLinker: node-modules So, as I see my problem, when executing the following $> rails new app_name -j esbuild -c bootstrap -d postgresql command generates the entire project structure, however, it does not generate the node_modules folder, which generates the > Error: Can't find stylesheet to import. │@import 'bootstrap/scss/bootstrap'; shown in the image. OS: Ubuntu-20.04 (WSL) |
@GregSmith92 removing the extension '.css' from the import path does the trick for me. Example: @import "select2/dist/css/select2"; |
@mopx Nice tip! To my surprise this does work!! |
Feel free to add a doc patch for this. |
I want to import a CSS module (in this case // import '@algolia/autocomplete-theme-classic'
export default class extends Controller {
connect() {
const shadowRoot = this.element.attachShadow({ mode: 'open' })
const style = document.createElement('style');
const autocompleteCss = 'https://cdn.jsdelivr.net/npm/@algolia/[email protected]/dist/theme.min.css';
style.textContent = `@import url(${autocompleteCss});`;
shadowRoot.appendChild(style);
}
} I want to give a CSS file in node_modules ( |
See discussion in issue #92 rails/cssbundling-rails#92
Uh oh!
There was an error while loading. Please reload this page.
I am moving from webpack to esbuild with jsbundling-rails & cssbundling-rails.
In a vendor directory I have a file which imports css files required by some JS packages like so:
This file is then imported in my
application.sass.scss
.In the logs I get a series of errors for each file like:
ActionController::RoutingError (No route matches [GET] "/assets/select2/dist/css/select2.css"):
It seems the problem may be that it is looking in
app/assets
for these files, when they are at the root undernode_modules
instead.In
config/initializers/assets
I haveRails.application.config.assets.paths << Rails.root.join('node_modules')
A similar issue was posted to the jsbundling-rails page (which I think should of been here), where OP added additional paths to config.assets, like so:
Rails.application.config.assets.paths << Rails.root.join("node_modules/photoswipe/src/css/default-skin")
, but this has not worked for me.The scripts I have in my package.json are:
EDITS:
I have noticed that only the css files fail to be found, the scss files work fine. Maybe coincidence, I am usnure
The text was updated successfully, but these errors were encountered: