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
CSS imports from node package fail on build, work on develop due to ~ confusion #5758
Comments
Do you have any expertise in how webpack should be setup to fix this? We're lacking in Sass experts here it seems so a PR from you fixing up gatsby-plugin-sass would be amazing! |
I have a fair amount of experience wrestling with webpack. Not sure if I have time, but I will try to have a look deeper. I'm not sure that it is sass related. This was a pure css file. Maybe it works if I convert it to sass. Notes for me or someone else: sass webpack loader should be: {
loader: 'sass-loader',
options: {
"includePaths": [
require('path').resolve(__dirname, 'node_modules')
]
}
} The css-loader docs are here: https://webpack.js.org/loaders/css-loader/ |
I have a similar styles import and don't have this issue with Gatsby v2 |
@crucialfelix FWIW, the non-tilde case seems to be fine if I configure (in {
resolve: `gatsby-plugin-sass`,
options: {
includePaths: [
require('path').resolve(__dirname, 'node_modules')
]
}
}, This is pretty much your suggested webpack loader config applied. |
Great, thanks for the responses ! I will try it and then see about a PR for 1.9. Looking forward to moving to 2 myself. |
I renamed This means that this gatsby-config.js works: {
resolve: `gatsby-plugin-sass`,
options: {
includePaths: [
require('path').resolve(__dirname, 'node_modules')
]
}
}, To get it work for css imports I think we can modify the base webpack config something like this: In module.exports = {
modifyWebpackConfig: function modifyWebpackConfig(config, env) {
config.merge({
resolve: {
include: [require("path").resolve(__dirname, "./node_modules")]
}
});
return config;
}
}; but apparently that is an out of date example and v1 docs: https://github.com/gatsbyjs/gatsby/blob/v1/docs/docs/add-custom-webpack-config.md So path of least resistance for me is to just use .scss files. This happens a lot with webpack. Exhaustion sets in, budget runs out, you take the first exit. |
Old issues will be closed after 30 days of inactivity. This issue has been quiet for 20 days and is being marked as stale. Reply here or add the label "not stale" to keep this issue open! |
This issue is being closed due to inactivity. Is this a mistake? Please re-open this issue or create a new issue. |
Description
CSS imports from a node package work in develop, but fail in build.
CSS imports in The Wacky World of Webpack are supposed to use a tilde:
~package
.gatsby develop
does NOT find the file if there is a tilde.gatsby build
does NOT find the file is there ISN'T a tilde.Steps to reproduce
layouts/index.js
layout.css
But that local file does work if included on
layouts/index.js
This works for the no-tilde imports.
This works only for the tilde imports.
Expected result
Builds
Actual result
build failure:
develop failure (with tilde):
Environment
File contents (if changed)
gatsby-config.js
: N/Apackage.json
: N/Agatsby-node.js
: N/Agatsby-browser.js
: N/Agatsby-ssr.js
: N/AThe text was updated successfully, but these errors were encountered: