Skip to content

feat: upgrade sass-loader support to ^8 #736

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

Closed
wants to merge 3 commits into from
Closed
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
6 changes: 4 additions & 2 deletions lib/loaders/sass.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,10 @@ module.exports = {
const config = Object.assign({}, {
// needed by the resolve-url-loader
sourceMap: (true === webpackConfig.sassOptions.resolveUrlLoader) || webpackConfig.useSourceMaps,
// CSS minification is handled with mini-css-extract-plugin
outputStyle: 'expanded'
sassOptions: {
// CSS minification is handled with mini-css-extract-plugin
outputStyle: 'expanded'
}
});

sassLoaders.push({
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
"style-loader": "^1.1.3",
"terser-webpack-plugin": "^1.1.0",
"tmp": "^0.0.33",
"webpack": "^4.20.0",
"webpack": "^4.36.1",
"webpack-cli": "^3.0.0",
"webpack-dev-server": "^3.1.14",
"webpack-manifest-plugin": "^2.0.2",
Expand Down Expand Up @@ -84,7 +84,7 @@
"preact": "^8.2.1",
"preact-compat": "^3.17.0",
"sass": "^1.17.0",
"sass-loader": "^7.0.1",
"sass-loader": "^8.0.0",
"sinon": "^2.3.4",
"strip-ansi": "^5.0.0",
"stylus": "^0.54.5",
Expand Down
2 changes: 1 addition & 1 deletion test/WebpackConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -842,7 +842,7 @@ describe('WebpackConfig object', () => {

it('Pass options callback', () => {
const config = createConfig();
const callback = (sassOptions) => {};
const callback = (options) => {};
config.enableSassLoader(callback);

expect(config.sassLoaderOptionsCallback).to.equal(callback);
Expand Down
18 changes: 10 additions & 8 deletions test/loaders/sass.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,18 +111,20 @@ describe('loaders/sass', () => {
sinon.stub(cssLoader, 'getLoaders')
.callsFake(() => []);

config.enableSassLoader(function(sassOptions) {
sassOptions.custom_optiona = 'baz';
sassOptions.other_option = true;
config.enableSassLoader(function(options) {
options.sassOptions.custom_option = 'baz';
options.sassOptions.other_option = true;
});

const actualLoaders = sassLoader.getLoaders(config);

expect(actualLoaders[1].options).to.deep.equals({
sourceMap: true,
outputStyle: 'expanded',
custom_optiona: 'baz',
other_option: true
sassOptions: {
outputStyle: 'expanded',
custom_option: 'baz',
other_option: true
}
});
cssLoader.getLoaders.restore();
});
Expand All @@ -134,8 +136,8 @@ describe('loaders/sass', () => {
sinon.stub(cssLoader, 'getLoaders')
.callsFake(() => []);

config.enableSassLoader(function(sassOptions) {
sassOptions.custom_option = 'baz';
config.enableSassLoader(function(options) {
options.custom_option = 'baz';

// This should override the original config
return { foo: true };
Expand Down
8 changes: 4 additions & 4 deletions test/package-helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ describe('package-helper', () => {
describe('The getInvalidPackageVersionRecommendations correctly checks installed versions', () => {
it('Check package that *is* the correct version', () => {
const versionProblems = packageHelper.getInvalidPackageVersionRecommendations([
{ name: 'sass-loader', version: '^7.0.1' },
{ name: 'sass-loader', version: '^8.0.0' },
{ name: 'preact', version: '^8.1.0' }
]);

Expand All @@ -132,17 +132,17 @@ describe('package-helper', () => {

it('Check package with a version too low', () => {
const versionProblems = packageHelper.getInvalidPackageVersionRecommendations([
{ name: 'sass-loader', version: '^8.0.1' },
{ name: 'sass-loader', version: '^9.0.0' },
{ name: 'preact', version: '9.0.0' }
]);

expect(versionProblems).to.have.length(2);
expect(versionProblems[0]).to.contain('is too old');
});

it('Check package with a version too low', () => {
it('Check package with a version too new', () => {
const versionProblems = packageHelper.getInvalidPackageVersionRecommendations([
{ name: 'sass-loader', version: '^6.9.11' },
{ name: 'sass-loader', version: '^7.0.1' },
{ name: 'preact', version: '7.0.0' }
]);

Expand Down
28 changes: 18 additions & 10 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -5110,7 +5110,7 @@ [email protected]:
emojis-list "^2.0.0"
json5 "^1.0.1"

loader-utils@^1.0.1, loader-utils@^1.0.2, loader-utils@^1.1.0, loader-utils@^1.2.3, loader-utils@^1.4.0:
loader-utils@^1.0.2, loader-utils@^1.1.0, loader-utils@^1.2.3, loader-utils@^1.4.0:
version "1.4.0"
resolved "https://registry.yarnpkg.com/loader-utils/-/loader-utils-1.4.0.tgz#c579b5e34cb34b1a74edc6c1fb36bfa371d5a613"
integrity sha512-qH0WSMBtn/oHuwjy/NucEgbx5dbxxnxup9s4PVXJUDHZBQY+s0NWA9rJf53RBnQZxfch7euUui7hpoAPvALZdA==
Expand Down Expand Up @@ -7324,15 +7324,15 @@ [email protected]:
scss-tokenizer "^0.2.3"
yargs "^13.3.2"

sass-loader@^7.0.1:
version "7.3.1"
resolved "https://registry.yarnpkg.com/sass-loader/-/sass-loader-7.3.1.tgz#a5bf68a04bcea1c13ff842d747150f7ab7d0d23f"
integrity sha512-tuU7+zm0pTCynKYHpdqaPpe+MMTQ76I9TPZ7i4/5dZsigE350shQWe5EZNl5dBidM49TPET75tNqRbcsUZWeNA==
sass-loader@^8.0.0:
version "8.0.2"
resolved "https://registry.yarnpkg.com/sass-loader/-/sass-loader-8.0.2.tgz#debecd8c3ce243c76454f2e8290482150380090d"
integrity sha512-7o4dbSK8/Ol2KflEmSco4jTjQoV988bM82P9CZdmo9hR3RLnvNc0ufMNdMrB0caq38JQ/FgF4/7RcbcfKzxoFQ==
dependencies:
clone-deep "^4.0.1"
loader-utils "^1.0.1"
neo-async "^2.5.0"
pify "^4.0.1"
loader-utils "^1.2.3"
neo-async "^2.6.1"
schema-utils "^2.6.1"
semver "^6.3.0"

sass@^1.17.0:
Expand All @@ -7356,14 +7356,22 @@ schema-utils@^1.0.0:
ajv-errors "^1.0.0"
ajv-keywords "^3.1.0"

schema-utils@^2.6.5, schema-utils@^2.6.6:
schema-utils@^2.6.1, schema-utils@^2.6.6:
version "2.6.6"
resolved "https://registry.yarnpkg.com/schema-utils/-/schema-utils-2.6.6.tgz#299fe6bd4a3365dc23d99fd446caff8f1d6c330c"
integrity sha512-wHutF/WPSbIi9x6ctjGGk2Hvl0VOz5l3EKEuKbjPlB30mKZUzb9A5k9yEXRX3pwyqVLPvpfZZEllaFq/M718hA==
dependencies:
ajv "^6.12.0"
ajv-keywords "^3.4.1"

schema-utils@^2.6.5:
version "2.6.5"
resolved "https://registry.yarnpkg.com/schema-utils/-/schema-utils-2.6.5.tgz#c758f0a7e624263073d396e29cd40aa101152d8a"
integrity sha512-5KXuwKziQrTVHh8j/Uxz+QUbxkaLW9X/86NBlx/gnKgtsZA2GIVMUn17qWhRFwF8jdYb3Dig5hRO/W5mZqy6SQ==
dependencies:
ajv "^6.12.0"
ajv-keywords "^3.4.1"

scss-tokenizer@^0.2.3:
version "0.2.3"
resolved "https://registry.yarnpkg.com/scss-tokenizer/-/scss-tokenizer-0.2.3.tgz#8eb06db9a9723333824d3f5530641149847ce5d1"
Expand Down Expand Up @@ -8717,7 +8725,7 @@ webpack-sources@^1.1.0, webpack-sources@^1.3.0, webpack-sources@^1.4.0, webpack-
source-list-map "^2.0.0"
source-map "~0.6.1"

webpack@^4.20.0:
webpack@^4.36.1:
version "4.43.0"
resolved "https://registry.yarnpkg.com/webpack/-/webpack-4.43.0.tgz#c48547b11d563224c561dad1172c8aa0b8a678e6"
integrity sha512-GW1LjnPipFW2Y78OOab8NJlCflB7EFskMih2AHdvjbpKMeDJqEgSx24cXXXiPS65+WSwVyxtDsJH6jGX2czy+g==
Expand Down