How to make SASS available to custom Webpack implementation in NextJS?
up vote
0
down vote
favorite
I'm trying to use the sass-resources-loader to have my SASS variables available in all my SASS files but it doesn't look like SASS is available to this loader.
The next-sass package docs suggest you can wrap the config object in order to make sass available to it. e.g withSass({configHere}).
However the error I get suggests that the SASS loader isn't available.
Config:
const path = require('path');
const withSass = require('
@zeit
/next-sass');
const globalSass = [
path.join(process.cwd(), 'stylesheets/variables/_variables.scss'),
path.join(process.cwd(), 'stylesheets/tools/_tools.scss')
]
module.exports = withSass({
webpack: (config, { buildId, dev, isServer, defaultLoaders }) => {
// Perform customizations to webpack config
// Important: return the modified config
config.module.rules.push({
loader: "sass-resources-loader",
options: {
resources: globalSass
}
})
return config
}
})
I am getting this error:
Module parse failed: Unexpected token (1:15)
You may need an appropriate loader to handle this file type.
> $font-size-base: 14px;
| $font-size-large: ceil(($font-size-base * 1.25));
| $font-size-small: ceil(($font-size-base * 0.85));
@multi ./node_modules/next/dist/client/next-dev
Where $font-size-base etc. are in the variables SASS file processed by "sass-resources-loader".
Could anyone suggest what I might be doing wrong here?
webpack sass next.js
add a comment |
up vote
0
down vote
favorite
I'm trying to use the sass-resources-loader to have my SASS variables available in all my SASS files but it doesn't look like SASS is available to this loader.
The next-sass package docs suggest you can wrap the config object in order to make sass available to it. e.g withSass({configHere}).
However the error I get suggests that the SASS loader isn't available.
Config:
const path = require('path');
const withSass = require('
@zeit
/next-sass');
const globalSass = [
path.join(process.cwd(), 'stylesheets/variables/_variables.scss'),
path.join(process.cwd(), 'stylesheets/tools/_tools.scss')
]
module.exports = withSass({
webpack: (config, { buildId, dev, isServer, defaultLoaders }) => {
// Perform customizations to webpack config
// Important: return the modified config
config.module.rules.push({
loader: "sass-resources-loader",
options: {
resources: globalSass
}
})
return config
}
})
I am getting this error:
Module parse failed: Unexpected token (1:15)
You may need an appropriate loader to handle this file type.
> $font-size-base: 14px;
| $font-size-large: ceil(($font-size-base * 1.25));
| $font-size-small: ceil(($font-size-base * 0.85));
@multi ./node_modules/next/dist/client/next-dev
Where $font-size-base etc. are in the variables SASS file processed by "sass-resources-loader".
Could anyone suggest what I might be doing wrong here?
webpack sass next.js
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I'm trying to use the sass-resources-loader to have my SASS variables available in all my SASS files but it doesn't look like SASS is available to this loader.
The next-sass package docs suggest you can wrap the config object in order to make sass available to it. e.g withSass({configHere}).
However the error I get suggests that the SASS loader isn't available.
Config:
const path = require('path');
const withSass = require('
@zeit
/next-sass');
const globalSass = [
path.join(process.cwd(), 'stylesheets/variables/_variables.scss'),
path.join(process.cwd(), 'stylesheets/tools/_tools.scss')
]
module.exports = withSass({
webpack: (config, { buildId, dev, isServer, defaultLoaders }) => {
// Perform customizations to webpack config
// Important: return the modified config
config.module.rules.push({
loader: "sass-resources-loader",
options: {
resources: globalSass
}
})
return config
}
})
I am getting this error:
Module parse failed: Unexpected token (1:15)
You may need an appropriate loader to handle this file type.
> $font-size-base: 14px;
| $font-size-large: ceil(($font-size-base * 1.25));
| $font-size-small: ceil(($font-size-base * 0.85));
@multi ./node_modules/next/dist/client/next-dev
Where $font-size-base etc. are in the variables SASS file processed by "sass-resources-loader".
Could anyone suggest what I might be doing wrong here?
webpack sass next.js
I'm trying to use the sass-resources-loader to have my SASS variables available in all my SASS files but it doesn't look like SASS is available to this loader.
The next-sass package docs suggest you can wrap the config object in order to make sass available to it. e.g withSass({configHere}).
However the error I get suggests that the SASS loader isn't available.
Config:
const path = require('path');
const withSass = require('
@zeit
/next-sass');
const globalSass = [
path.join(process.cwd(), 'stylesheets/variables/_variables.scss'),
path.join(process.cwd(), 'stylesheets/tools/_tools.scss')
]
module.exports = withSass({
webpack: (config, { buildId, dev, isServer, defaultLoaders }) => {
// Perform customizations to webpack config
// Important: return the modified config
config.module.rules.push({
loader: "sass-resources-loader",
options: {
resources: globalSass
}
})
return config
}
})
I am getting this error:
Module parse failed: Unexpected token (1:15)
You may need an appropriate loader to handle this file type.
> $font-size-base: 14px;
| $font-size-large: ceil(($font-size-base * 1.25));
| $font-size-small: ceil(($font-size-base * 0.85));
@multi ./node_modules/next/dist/client/next-dev
Where $font-size-base etc. are in the variables SASS file processed by "sass-resources-loader".
Could anyone suggest what I might be doing wrong here?
webpack sass next.js
webpack sass next.js
asked Nov 20 at 9:04
Antfish
448519
448519
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
up vote
2
down vote
accepted
I have a couple of suggestions.
You don’t have a test for your rule:
test: /.scss$/
You’ll probably also need to force the sass-resources-loader to run first, before the other loaders, by using:
enforce: 'pre'
So, try this config:
module.exports = withSass({
webpack: (config, { buildId, dev, isServer, defaultLoaders }) => {
config.module.rules.push({
enforce: "pre",
test: /.scss$/,
loader: "sass-resources-loader",
options: {
resources: globalSass
}
})
return config
}
})
Hopefully this will work for you.
Awesome this worked! I think the enforce: "pre" was key. Wasn't away of this property. Thanks!
– Antfish
Nov 23 at 21:57
Glad this helped you out :)
– Steve Holgado
Nov 24 at 0:44
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
2
down vote
accepted
I have a couple of suggestions.
You don’t have a test for your rule:
test: /.scss$/
You’ll probably also need to force the sass-resources-loader to run first, before the other loaders, by using:
enforce: 'pre'
So, try this config:
module.exports = withSass({
webpack: (config, { buildId, dev, isServer, defaultLoaders }) => {
config.module.rules.push({
enforce: "pre",
test: /.scss$/,
loader: "sass-resources-loader",
options: {
resources: globalSass
}
})
return config
}
})
Hopefully this will work for you.
Awesome this worked! I think the enforce: "pre" was key. Wasn't away of this property. Thanks!
– Antfish
Nov 23 at 21:57
Glad this helped you out :)
– Steve Holgado
Nov 24 at 0:44
add a comment |
up vote
2
down vote
accepted
I have a couple of suggestions.
You don’t have a test for your rule:
test: /.scss$/
You’ll probably also need to force the sass-resources-loader to run first, before the other loaders, by using:
enforce: 'pre'
So, try this config:
module.exports = withSass({
webpack: (config, { buildId, dev, isServer, defaultLoaders }) => {
config.module.rules.push({
enforce: "pre",
test: /.scss$/,
loader: "sass-resources-loader",
options: {
resources: globalSass
}
})
return config
}
})
Hopefully this will work for you.
Awesome this worked! I think the enforce: "pre" was key. Wasn't away of this property. Thanks!
– Antfish
Nov 23 at 21:57
Glad this helped you out :)
– Steve Holgado
Nov 24 at 0:44
add a comment |
up vote
2
down vote
accepted
up vote
2
down vote
accepted
I have a couple of suggestions.
You don’t have a test for your rule:
test: /.scss$/
You’ll probably also need to force the sass-resources-loader to run first, before the other loaders, by using:
enforce: 'pre'
So, try this config:
module.exports = withSass({
webpack: (config, { buildId, dev, isServer, defaultLoaders }) => {
config.module.rules.push({
enforce: "pre",
test: /.scss$/,
loader: "sass-resources-loader",
options: {
resources: globalSass
}
})
return config
}
})
Hopefully this will work for you.
I have a couple of suggestions.
You don’t have a test for your rule:
test: /.scss$/
You’ll probably also need to force the sass-resources-loader to run first, before the other loaders, by using:
enforce: 'pre'
So, try this config:
module.exports = withSass({
webpack: (config, { buildId, dev, isServer, defaultLoaders }) => {
config.module.rules.push({
enforce: "pre",
test: /.scss$/,
loader: "sass-resources-loader",
options: {
resources: globalSass
}
})
return config
}
})
Hopefully this will work for you.
answered Nov 23 at 8:46
Steve Holgado
3,201249
3,201249
Awesome this worked! I think the enforce: "pre" was key. Wasn't away of this property. Thanks!
– Antfish
Nov 23 at 21:57
Glad this helped you out :)
– Steve Holgado
Nov 24 at 0:44
add a comment |
Awesome this worked! I think the enforce: "pre" was key. Wasn't away of this property. Thanks!
– Antfish
Nov 23 at 21:57
Glad this helped you out :)
– Steve Holgado
Nov 24 at 0:44
Awesome this worked! I think the enforce: "pre" was key. Wasn't away of this property. Thanks!
– Antfish
Nov 23 at 21:57
Awesome this worked! I think the enforce: "pre" was key. Wasn't away of this property. Thanks!
– Antfish
Nov 23 at 21:57
Glad this helped you out :)
– Steve Holgado
Nov 24 at 0:44
Glad this helped you out :)
– Steve Holgado
Nov 24 at 0:44
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53389523%2fhow-to-make-sass-available-to-custom-webpack-implementation-in-nextjs%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown