Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ This allows you to control the versions of all your dependencies and to choose w
>
> [Node Sass](https://github.com/sass/node-sass) does not work with [Yarn PnP](https://classic.yarnpkg.com/en/docs/pnp/) and doesn't support [@use rule](https://sass-lang.com/documentation/at-rules/use).

Chain the `sass-loader` with the [css-loader](https://github.com/webpack-contrib/css-loader) and the [style-loader](https://github.com/webpack-contrib/style-loader) to immediately apply all styles to the DOM, or with the [mini-css-extract-plugin](https://github.com/webpack-contrib/mini-css-extract-plugin) to extract it into a separate file.
Chain the `sass-loader` with the [css-loader](https://github.com/webpack/css-loader) and the [style-loader](https://github.com/webpack/style-loader) to immediately apply all styles to the DOM, or with the [mini-css-extract-plugin](https://github.com/webpack-contrib/mini-css-extract-plugin) to extract it into a separate file.

Then add the loader to your webpack configuration. For example:

Expand Down Expand Up @@ -887,7 +887,7 @@ module.exports = {
```

If you want to edit the original Sass files inside Chrome, [there's a good blog post](https://medium.com/@toolmantim/getting-started-with-css-sourcemaps-and-in-browser-sass-editing-b4daab987fb0).
Checkout [test/sourceMap](https://github.com/webpack-contrib/sass-loader/tree/main/test) for a working example.
Checkout [test/sourceMap](https://github.com/webpack/sass-loader/tree/main/test) for a working example.

## Contributing

Expand All @@ -904,10 +904,10 @@ If you're new here, please take a moment to review our contributing guidelines b
[npm-url]: https://npmjs.com/package/sass-loader
[node]: https://img.shields.io/node/v/sass-loader.svg
[node-url]: https://nodejs.org
[tests]: https://github.com/webpack-contrib/sass-loader/workflows/sass-loader/badge.svg
[tests-url]: https://github.com/webpack-contrib/sass-loader/actions
[cover]: https://codecov.io/gh/webpack-contrib/sass-loader/branch/main/graph/badge.svg
[cover-url]: https://codecov.io/gh/webpack-contrib/sass-loader
[tests]: https://github.com/webpack/sass-loader/workflows/sass-loader/badge.svg
[tests-url]: https://github.com/webpack/sass-loader/actions
[cover]: https://codecov.io/gh/webpack/sass-loader/branch/main/graph/badge.svg
[cover-url]: https://codecov.io/gh/webpack/sass-loader
[discussion]: https://img.shields.io/github/discussions/webpack/webpack
[discussion-url]: https://github.com/webpack/webpack/discussions
[size]: https://packagephobia.now.sh/badge?p=sass-loader
Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
"webpack",
"loader"
],
"homepage": "https://github.com/webpack-contrib/sass-loader",
"bugs": "https://github.com/webpack-contrib/sass-loader/issues",
"repository": "webpack-contrib/sass-loader",
"homepage": "https://github.com/webpack/sass-loader",
"bugs": "https://github.com/webpack/sass-loader/issues",
"repository": "webpack/sass-loader",
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/webpack"
Expand Down
14 changes: 7 additions & 7 deletions src/options.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"properties": {
"implementation": {
"description": "The implementation of the sass to be used.",
"link": "https://github.com/webpack-contrib/sass-loader#implementation",
"link": "https://github.com/webpack/sass-loader#implementation",
"anyOf": [
{
"type": "string"
Expand All @@ -16,12 +16,12 @@
},
"api": {
"description": "Switch between old and modern API for `sass` (`Dart Sass`) and `Sass Embedded` implementations.",
"link": "https://github.com/webpack-contrib/sass-loader#sassoptions",
"link": "https://github.com/webpack/sass-loader#sassoptions",
"enum": ["legacy", "modern", "modern-compiler"]
},
"sassOptions": {
"description": "Options for `node-sass` or `sass` (`Dart Sass`) implementation.",
"link": "https://github.com/webpack-contrib/sass-loader#sassoptions",
"link": "https://github.com/webpack/sass-loader#sassoptions",
"anyOf": [
{
"type": "object",
Expand All @@ -34,7 +34,7 @@
},
"additionalData": {
"description": "Prepends/Appends `Sass`/`SCSS` code before the actual entry file.",
"link": "https://github.com/webpack-contrib/sass-loader#additionaldata",
"link": "https://github.com/webpack/sass-loader#additionaldata",
"anyOf": [
{
"type": "string"
Expand All @@ -46,17 +46,17 @@
},
"sourceMap": {
"description": "Enables/Disables generation of source maps.",
"link": "https://github.com/webpack-contrib/sass-loader#sourcemap",
"link": "https://github.com/webpack/sass-loader#sourcemap",
"type": "boolean"
},
"webpackImporter": {
"description": "Enables/Disables default `webpack` importer.",
"link": "https://github.com/webpack-contrib/sass-loader#webpackimporter",
"link": "https://github.com/webpack/sass-loader#webpackimporter",
"type": "boolean"
},
"warnRuleAsWarning": {
"description": "Treats the '@warn' rule as a webpack warning.",
"link": "https://github.com/webpack-contrib/sass-loader#warnruleaswarning",
"link": "https://github.com/webpack/sass-loader#warnruleaswarning",
"type": "boolean"
}
},
Expand Down
4 changes: 2 additions & 2 deletions src/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,7 @@ function getPossibleRequests(
}

// Keep in mind: ext can also be something like '.datepicker' when the true extension is omitted and the filename contains a dot.
// @see https://github.com/webpack-contrib/sass-loader/issues/167
// @see https://github.com/webpack/sass/issues/167
const extension = path.extname(request).toLowerCase();

// Because @import is also defined in CSS, Sass needs a way of compiling plain CSS @imports without trying to import the files at compile time.
Expand Down Expand Up @@ -893,7 +893,7 @@ function normalizeSourceMap(map, rootContext) {

// node-sass returns POSIX paths, that's why we need to transform them back to native paths.
// This fixes an error on windows where the source-map module cannot resolve the source maps.
// @see https://github.com/webpack-contrib/sass-loader/issues/366#issuecomment-279460722
// @see https://github.com/webpack/sass-loader/issues/366#issuecomment-279460722

newMap.sources = newMap.sources.map((source) => {
const sourceType = getURLType(source);
Expand Down
20 changes: 10 additions & 10 deletions test/__snapshots__/validate-options.test.js.no-node-sass.snap
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ exports[`validate options should throw an error on the "additionalData" option w
- options.additionalData should be one of these:
string | function
-> Prepends/Appends \`Sass\`/\`SCSS\` code before the actual entry file.
-> Read more at https://github.com/webpack-contrib/sass-loader#additionaldata
-> Read more at https://github.com/webpack/sass-loader#additionaldata
Details:
* options.additionalData should be a string.
* options.additionalData should be an instance of function."
Expand All @@ -16,23 +16,23 @@ exports[`validate options should throw an error on the "api" option with "string
- options.api should be one of these:
"legacy" | "modern" | "modern-compiler"
-> Switch between old and modern API for \`sass\` (\`Dart Sass\`) and \`Sass Embedded\` implementations.
-> Read more at https://github.com/webpack-contrib/sass-loader#sassoptions"
-> Read more at https://github.com/webpack/sass-loader#sassoptions"
`;

exports[`validate options should throw an error on the "api" option with "true" value 1`] = `
"Invalid options object. Sass Loader has been initialized using an options object that does not match the API schema.
- options.api should be one of these:
"legacy" | "modern" | "modern-compiler"
-> Switch between old and modern API for \`sass\` (\`Dart Sass\`) and \`Sass Embedded\` implementations.
-> Read more at https://github.com/webpack-contrib/sass-loader#sassoptions"
-> Read more at https://github.com/webpack/sass-loader#sassoptions"
`;

exports[`validate options should throw an error on the "implementation" option with "() => {}" value 1`] = `
"Invalid options object. Sass Loader has been initialized using an options object that does not match the API schema.
- options.implementation should be one of these:
string | object { … }
-> The implementation of the sass to be used.
-> Read more at https://github.com/webpack-contrib/sass-loader#implementation
-> Read more at https://github.com/webpack/sass-loader#implementation
Details:
* options.implementation should be a string.
* options.implementation should be an object:
Expand All @@ -44,7 +44,7 @@ exports[`validate options should throw an error on the "implementation" option w
- options.implementation should be one of these:
string | object { … }
-> The implementation of the sass to be used.
-> Read more at https://github.com/webpack-contrib/sass-loader#implementation
-> Read more at https://github.com/webpack/sass-loader#implementation
Details:
* options.implementation should be a string.
* options.implementation should be an object:
Expand All @@ -56,7 +56,7 @@ exports[`validate options should throw an error on the "sassOptions" option with
- options.sassOptions should be one of these:
object { … } | function
-> Options for \`node-sass\` or \`sass\` (\`Dart Sass\`) implementation.
-> Read more at https://github.com/webpack-contrib/sass-loader#sassoptions
-> Read more at https://github.com/webpack/sass-loader#sassoptions
Details:
* options.sassOptions should be an object:
object { … }
Expand All @@ -68,7 +68,7 @@ exports[`validate options should throw an error on the "sassOptions" option with
- options.sassOptions should be one of these:
object { … } | function
-> Options for \`node-sass\` or \`sass\` (\`Dart Sass\`) implementation.
-> Read more at https://github.com/webpack-contrib/sass-loader#sassoptions
-> Read more at https://github.com/webpack/sass-loader#sassoptions
Details:
* options.sassOptions should be an object:
object { … }
Expand All @@ -79,7 +79,7 @@ exports[`validate options should throw an error on the "sourceMap" option with "
"Invalid options object. Sass Loader has been initialized using an options object that does not match the API schema.
- options.sourceMap should be a boolean.
-> Enables/Disables generation of source maps.
-> Read more at https://github.com/webpack-contrib/sass-loader#sourcemap"
-> Read more at https://github.com/webpack/sass-loader#sourcemap"
`;

exports[`validate options should throw an error on the "unknown" option with "/test/" value 1`] = `
Expand Down Expand Up @@ -134,12 +134,12 @@ exports[`validate options should throw an error on the "warnRuleAsWarning" optio
"Invalid options object. Sass Loader has been initialized using an options object that does not match the API schema.
- options.warnRuleAsWarning should be a boolean.
-> Treats the '@warn' rule as a webpack warning.
-> Read more at https://github.com/webpack-contrib/sass-loader#warnruleaswarning"
-> Read more at https://github.com/webpack/sass-loader#warnruleaswarning"
`;

exports[`validate options should throw an error on the "webpackImporter" option with "string" value 1`] = `
"Invalid options object. Sass Loader has been initialized using an options object that does not match the API schema.
- options.webpackImporter should be a boolean.
-> Enables/Disables default \`webpack\` importer.
-> Read more at https://github.com/webpack-contrib/sass-loader#webpackimporter"
-> Read more at https://github.com/webpack/sass-loader#webpackimporter"
`;
20 changes: 10 additions & 10 deletions test/__snapshots__/validate-options.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ exports[`validate options should throw an error on the "additionalData" option w
- options.additionalData should be one of these:
string | function
-> Prepends/Appends \`Sass\`/\`SCSS\` code before the actual entry file.
-> Read more at https://github.com/webpack-contrib/sass-loader#additionaldata
-> Read more at https://github.com/webpack/sass-loader#additionaldata
Details:
* options.additionalData should be a string.
* options.additionalData should be an instance of function."
Expand All @@ -16,23 +16,23 @@ exports[`validate options should throw an error on the "api" option with "string
- options.api should be one of these:
"legacy" | "modern" | "modern-compiler"
-> Switch between old and modern API for \`sass\` (\`Dart Sass\`) and \`Sass Embedded\` implementations.
-> Read more at https://github.com/webpack-contrib/sass-loader#sassoptions"
-> Read more at https://github.com/webpack/sass-loader#sassoptions"
`;

exports[`validate options should throw an error on the "api" option with "true" value 1`] = `
"Invalid options object. Sass Loader has been initialized using an options object that does not match the API schema.
- options.api should be one of these:
"legacy" | "modern" | "modern-compiler"
-> Switch between old and modern API for \`sass\` (\`Dart Sass\`) and \`Sass Embedded\` implementations.
-> Read more at https://github.com/webpack-contrib/sass-loader#sassoptions"
-> Read more at https://github.com/webpack/sass-loader#sassoptions"
`;

exports[`validate options should throw an error on the "implementation" option with "() => {}" value 1`] = `
"Invalid options object. Sass Loader has been initialized using an options object that does not match the API schema.
- options.implementation should be one of these:
string | object { … }
-> The implementation of the sass to be used.
-> Read more at https://github.com/webpack-contrib/sass-loader#implementation
-> Read more at https://github.com/webpack/sass-loader#implementation
Details:
* options.implementation should be a string.
* options.implementation should be an object:
Expand All @@ -44,7 +44,7 @@ exports[`validate options should throw an error on the "implementation" option w
- options.implementation should be one of these:
string | object { … }
-> The implementation of the sass to be used.
-> Read more at https://github.com/webpack-contrib/sass-loader#implementation
-> Read more at https://github.com/webpack/sass-loader#implementation
Details:
* options.implementation should be a string.
* options.implementation should be an object:
Expand All @@ -56,7 +56,7 @@ exports[`validate options should throw an error on the "sassOptions" option with
- options.sassOptions should be one of these:
object { … } | function
-> Options for \`node-sass\` or \`sass\` (\`Dart Sass\`) implementation.
-> Read more at https://github.com/webpack-contrib/sass-loader#sassoptions
-> Read more at https://github.com/webpack/sass-loader#sassoptions
Details:
* options.sassOptions should be an object:
object { … }
Expand All @@ -68,7 +68,7 @@ exports[`validate options should throw an error on the "sassOptions" option with
- options.sassOptions should be one of these:
object { … } | function
-> Options for \`node-sass\` or \`sass\` (\`Dart Sass\`) implementation.
-> Read more at https://github.com/webpack-contrib/sass-loader#sassoptions
-> Read more at https://github.com/webpack/sass-loader#sassoptions
Details:
* options.sassOptions should be an object:
object { … }
Expand All @@ -79,7 +79,7 @@ exports[`validate options should throw an error on the "sourceMap" option with "
"Invalid options object. Sass Loader has been initialized using an options object that does not match the API schema.
- options.sourceMap should be a boolean.
-> Enables/Disables generation of source maps.
-> Read more at https://github.com/webpack-contrib/sass-loader#sourcemap"
-> Read more at https://github.com/webpack/sass-loader#sourcemap"
`;

exports[`validate options should throw an error on the "unknown" option with "/test/" value 1`] = `
Expand Down Expand Up @@ -134,12 +134,12 @@ exports[`validate options should throw an error on the "warnRuleAsWarning" optio
"Invalid options object. Sass Loader has been initialized using an options object that does not match the API schema.
- options.warnRuleAsWarning should be a boolean.
-> Treats the '@warn' rule as a webpack warning.
-> Read more at https://github.com/webpack-contrib/sass-loader#warnruleaswarning"
-> Read more at https://github.com/webpack/sass-loader#warnruleaswarning"
`;

exports[`validate options should throw an error on the "webpackImporter" option with "string" value 1`] = `
"Invalid options object. Sass Loader has been initialized using an options object that does not match the API schema.
- options.webpackImporter should be a boolean.
-> Enables/Disables default \`webpack\` importer.
-> Read more at https://github.com/webpack-contrib/sass-loader#webpackimporter"
-> Read more at https://github.com/webpack/sass-loader#webpackimporter"
`;
6 changes: 3 additions & 3 deletions test/loader.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ describe("loader", () => {
await close(compiler);
});

// Test for issue: https://github.com/webpack-contrib/sass-loader/issues/32
// Test for issue: https://github.com/webpack/sass-loader/issues/32
it(`should work with multiple "@import" at-rules ('${implementationName}', '${api}' API, '${syntax}' syntax)`, async () => {
const testId = getTestId("multiple-imports", syntax);
const options = {
Expand All @@ -286,7 +286,7 @@ describe("loader", () => {
await close(compiler);
});

// Test for issue: https://github.com/webpack-contrib/sass-loader/issues/73
// Test for issue: https://github.com/webpack/sass-loader/issues/73
it(`should work with "@import" at-rules from other language style ('${implementationName}', '${api}' API, '${syntax}' syntax)`, async () => {
const testId = getTestId("import-other-style", syntax);
const options = {
Expand Down Expand Up @@ -708,7 +708,7 @@ describe("loader", () => {
});

// Legacy support for CSS imports with node-sass
// See discussion https://github.com/webpack-contrib/sass-loader/pull/573/files?#r199109203
// See discussion https://github.com/webpack/sass-loader/pull/573/files?#r199109203
it(`should work and ignore all css "@import" at-rules ('${implementationName}', '${api}' API, '${syntax}' syntax)`, async () => {
const testId = getTestId("import-css", syntax);
const options = {
Expand Down
4 changes: 2 additions & 2 deletions test/sass/imports.sass
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
/* @import ~sass/underscore */
@import ~sass/underscore
// Import a module with a dot in its name
// @see https://github.com/webpack-contrib/sass-loader/issues/167
// @see https://github.com/webpack/sass-loader/issues/167
/* @import ~sass/some.module */
@import ~sass/some.module
/* @import url(http://example.com/something/from/the/interwebs); */
Expand All @@ -17,7 +17,7 @@
@import language

// The local util file should take precedence over Node's util module
// See https://github.com/webpack-contrib/sass-loader/issues/556
// See https://github.com/webpack/sass-loader/issues/556
/* @import util */
@import util
/* @import ~module */
Expand Down
4 changes: 2 additions & 2 deletions test/sass/uses.sass
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@
/* @use ~sass/underscore */
@use "~sass/underscore" as underscore3
// Import a module with a dot in its name
// @see https://github.com/webpack-contrib/sass-loader/issues/167
// @see https://github.com/webpack/sass-loader/issues/167
/* @use ~sass/some.module */
@use "~sass/some.module"
// The local util file should take precedence over Node's util module
// See https://github.com/webpack-contrib/sass-loader/issues/556
// See https://github.com/webpack/sass-loader/issues/556
/* @use util */
@use "util"
/* @use ~module */
Expand Down
2 changes: 1 addition & 1 deletion test/scss/another/module.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// ./another/module.js: The sass-loader should not try to import that. scss, sass and css extensions should be preferred.
// See https://github.com/webpack-contrib/sass-loader/issues/556#issuecomment-381154009
// See https://github.com/webpack/sass-loader/issues/556#issuecomment-381154009

"This should not be imported";
Loading