Can't use @mixins
See original GitHub issueHaving another issue with this loader pertaining to Mixins. For years have just done something like:
@mixin [breakpoint]{
@media only screen and (min-width: [breakpoint]){
@content;
}
}
But now I’m getting errors trying to do Mixins
error
ERROR in ./src/index.scss
Module build failed: ModuleBuildError: Module build failed: Undefined mixin break-xs (3:1)
1 | @import "../settings/breakpoints.scss";
2 |
> 3 | @mixin break-xs {
...
index.jsx
require('./index.scss');
index.scss
@import "assets/stylesheets/settings/breakpoints.scss";
@import "assets/stylesheets/tools/media-queries";
media-queries.scss
@mixin break-xs {
@media only screen and (min-width: $screen-xs) {
@content;
}
}
I’ve also added import "../settings/breakpoints.scss";
to the top of the file because I was reading in places that you may have to import resources since Webpack silos global variables with my other declarations so jury still out on that.
webpack.config
...
{
test: /\.(s?)css$/,
use: ExtractTextPlugin.extract({
fallback: 'style-loader',
use: ['css-loader', 'sass-loader', 'resolve-url-loader', 'postcss-loader']
})
},
...
new ExtractTextPlugin({
filename: 'app.css',
disable: false,
allChunks: true
}),
...
- Webpack 2.2.1
- node-sass 4.5.0
- sass-loader 6.0.2
- style-loader 0.13.2
- postcss-loader 1.3.5
- extract-text-webpack-plugin 2.0.2
Issue Analytics
- State:
- Created 7 years ago
- Reactions:4
- Comments:7 (3 by maintainers)
Top Results From Across the Web
Can't @use mixin, but can @import · Issue #2858 · sass/sass
I have a top-level file that only has: @mixin bg_img($path) { background-image: url("http://localhost:4102/app/ui/" + $path); } If I @import ...
Read more >Sass mixin not being imported or compiled - Stack Overflow
I'm using webpack 4 and the mini-css-extract-plugin along with sass-loader / node-sass to compile my sass into css.
Read more >How to import Sass/SCSS mixins global? - DEV Community
Something you could try: import that global sass file right into the react component using @import "..."; and see what happens. In previous...
Read more >Sass: @import
Although Sass imports can't use interpolation (to make sure it's always possible to tell where mixins, functions, and variables come from), plain CSS...
Read more >How to use mixins and custom functions in Vue
Vue mixins and directives allow you to further extend your application and write more readable code by minimizing moving parts.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@wsfuller Then you should create
migration-from-gulp-and-grunt.md
and move this docs inwebpack-docs
, not hereHi! I wonder how we can achieve this with Webpack 5.
I’m trying to build css files from scss like: resources/scss/button.scss to src/components/button.css which should be pretty straight forward but because in buttons.scss I have “@ include” rules I can’t find a way to do that. I d expect webpack to resolve the “@ includes” (resources/scss/mixins).
Sorry if I’m asking in the wrong place but this thread seems to be the closest working solution (at least for wp2). Thank you so much!