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
1 change: 1 addition & 0 deletions src/getSassOptions.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ function getSassOptions(loaderContext, loaderOptions, content, implementation) {
? process.env.SASS_PATH.split(process.platform === 'win32' ? ';' : ':')
: []
)
.concat(process.cwd())
.concat(path.dirname(resourcePath));

return options;
Expand Down
68 changes: 56 additions & 12 deletions test/__snapshots__/loader.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,51 @@ SassError: expected \\"{\\".",

exports[`loader should output an understandable error with a problem in "@use" (dart-sass) (scss): warnings 1`] = `Array []`;

exports[`loader should respect the "SASS_PATH" environment variable (dart-sass) (sass): css 1`] = `
exports[`loader should respect resolving from "process.cwd()" (dart-sass) (sass): css 1`] = `
"body {
font: 100% Helvetica, sans-serif;
color: #333;
}"
`;

exports[`loader should respect resolving from "process.cwd()" (dart-sass) (sass): errors 1`] = `Array []`;

exports[`loader should respect resolving from "process.cwd()" (dart-sass) (sass): warnings 1`] = `Array []`;

exports[`loader should respect resolving from "process.cwd()" (dart-sass) (scss): css 1`] = `
"body {
font: 100% Helvetica, sans-serif;
color: #333;
}"
`;

exports[`loader should respect resolving from "process.cwd()" (dart-sass) (scss): errors 1`] = `Array []`;

exports[`loader should respect resolving from "process.cwd()" (dart-sass) (scss): warnings 1`] = `Array []`;

exports[`loader should respect resolving from "process.cwd()" (node-sass) (sass): css 1`] = `
"body {
font: 100% Helvetica, sans-serif;
color: #333; }
"
`;

exports[`loader should respect resolving from "process.cwd()" (node-sass) (sass): errors 1`] = `Array []`;

exports[`loader should respect resolving from "process.cwd()" (node-sass) (sass): warnings 1`] = `Array []`;

exports[`loader should respect resolving from "process.cwd()" (node-sass) (scss): css 1`] = `
"body {
font: 100% Helvetica, sans-serif;
color: #333; }
"
`;

exports[`loader should respect resolving from "process.cwd()" (node-sass) (scss): errors 1`] = `Array []`;

exports[`loader should respect resolving from "process.cwd()" (node-sass) (scss): warnings 1`] = `Array []`;

exports[`loader should respect resolving from the "SASS_PATH" environment variable (dart-sass) (sass): css 1`] = `
".foo {
color: red;
}
Expand All @@ -234,11 +278,11 @@ exports[`loader should respect the "SASS_PATH" environment variable (dart-sass)
}"
`;

exports[`loader should respect the "SASS_PATH" environment variable (dart-sass) (sass): errors 1`] = `Array []`;
exports[`loader should respect resolving from the "SASS_PATH" environment variable (dart-sass) (sass): errors 1`] = `Array []`;

exports[`loader should respect the "SASS_PATH" environment variable (dart-sass) (sass): warnings 1`] = `Array []`;
exports[`loader should respect resolving from the "SASS_PATH" environment variable (dart-sass) (sass): warnings 1`] = `Array []`;

exports[`loader should respect the "SASS_PATH" environment variable (dart-sass) (scss): css 1`] = `
exports[`loader should respect resolving from the "SASS_PATH" environment variable (dart-sass) (scss): css 1`] = `
".foo {
color: red;
}
Expand All @@ -248,11 +292,11 @@ exports[`loader should respect the "SASS_PATH" environment variable (dart-sass)
}"
`;

exports[`loader should respect the "SASS_PATH" environment variable (dart-sass) (scss): errors 1`] = `Array []`;
exports[`loader should respect resolving from the "SASS_PATH" environment variable (dart-sass) (scss): errors 1`] = `Array []`;

exports[`loader should respect the "SASS_PATH" environment variable (dart-sass) (scss): warnings 1`] = `Array []`;
exports[`loader should respect resolving from the "SASS_PATH" environment variable (dart-sass) (scss): warnings 1`] = `Array []`;

exports[`loader should respect the "SASS_PATH" environment variable (node-sass) (sass): css 1`] = `
exports[`loader should respect resolving from the "SASS_PATH" environment variable (node-sass) (sass): css 1`] = `
".foo {
color: red; }

Expand All @@ -261,11 +305,11 @@ exports[`loader should respect the "SASS_PATH" environment variable (node-sass)
"
`;

exports[`loader should respect the "SASS_PATH" environment variable (node-sass) (sass): errors 1`] = `Array []`;
exports[`loader should respect resolving from the "SASS_PATH" environment variable (node-sass) (sass): errors 1`] = `Array []`;

exports[`loader should respect the "SASS_PATH" environment variable (node-sass) (sass): warnings 1`] = `Array []`;
exports[`loader should respect resolving from the "SASS_PATH" environment variable (node-sass) (sass): warnings 1`] = `Array []`;

exports[`loader should respect the "SASS_PATH" environment variable (node-sass) (scss): css 1`] = `
exports[`loader should respect resolving from the "SASS_PATH" environment variable (node-sass) (scss): css 1`] = `
".foo {
color: red; }

Expand All @@ -274,9 +318,9 @@ exports[`loader should respect the "SASS_PATH" environment variable (node-sass)
"
`;

exports[`loader should respect the "SASS_PATH" environment variable (node-sass) (scss): errors 1`] = `Array []`;
exports[`loader should respect resolving from the "SASS_PATH" environment variable (node-sass) (scss): errors 1`] = `Array []`;

exports[`loader should respect the "SASS_PATH" environment variable (node-sass) (scss): warnings 1`] = `Array []`;
exports[`loader should respect resolving from the "SASS_PATH" environment variable (node-sass) (scss): warnings 1`] = `Array []`;

exports[`loader should throw an error with a explicit file and a file does not exist (dart-sass) (sass): errors 1`] = `
Array [
Expand Down
18 changes: 17 additions & 1 deletion test/loader.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -655,7 +655,7 @@ describe('loader', () => {
expect(getErrors(stats)).toMatchSnapshot('errors');
});

it(`should respect the "SASS_PATH" environment variable (${implementationName}) (${syntax})`, async () => {
it(`should respect resolving from the "SASS_PATH" environment variable (${implementationName}) (${syntax})`, async () => {
const OLD_SASS_PATH = process.env.SASS_PATH;

process.env.SASS_PATH =
Expand Down Expand Up @@ -688,6 +688,22 @@ describe('loader', () => {
process.env.SASS_PATH = OLD_SASS_PATH;
});

it(`should respect resolving from "process.cwd()" (${implementationName}) (${syntax})`, async () => {
const testId = getTestId('process-cwd', syntax);
const options = {
implementation: getImplementationByName(implementationName),
};
const compiler = getCompiler(testId, { loader: { options } });
const stats = await compile(compiler);
const codeFromBundle = getCodeFromBundle(stats, compiler);
const codeFromSass = getCodeFromSass(testId, options);

expect(codeFromBundle.css).toBe(codeFromSass.css);
expect(codeFromBundle.css).toMatchSnapshot('css');
expect(getWarnings(stats)).toMatchSnapshot('warnings');
expect(getErrors(stats)).toMatchSnapshot('errors');
});

if (implementation === dartSass) {
it(`should output an understandable error with a problem in "@use" (${implementationName}) (${syntax})`, async () => {
const testId = getTestId('error-use', syntax);
Expand Down
1 change: 1 addition & 0 deletions test/sass/process-cwd.sass
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
@import 'test/sass/simple'
6 changes: 6 additions & 0 deletions test/sass/simple.sass
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
$font-stack: Helvetica, sans-serif
$primary-color: #333

body
font: 100% $font-stack
color: $primary-color
1 change: 1 addition & 0 deletions test/scss/process-cwd.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
@import 'test/scss/simple';