Skip to content

Commit b9e42be

Browse files
David EllingsworthDavid Ellingsworth
David Ellingsworth
authored and
David Ellingsworth
committed
Add functional test for sass imports via package.json sass property
1 parent 0f9657f commit b9e42be

File tree

5 files changed

+42
-0
lines changed

5 files changed

+42
-0
lines changed

fixtures/css/sass_package_import.scss

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
// There seems to be an issue with the sass-loader and prefixing
2+
// aliased directories with a tilde. The following line is how
3+
// this import should look and works for node_modules.
4+
// @import '~lib/test-pkg';
5+
6+
// Importing without the tilde seems to work for webpack aliases
7+
@import 'lib/test-pkg';
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
$content:'Sass entrypoint';
2+
3+
body {
4+
content:$content;
5+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
"use strict";
2+
3+
document.write("JavaScript entrypoint");

fixtures/lib/test-pkg/package.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"name":"@symfony/webpack-encore-test-pkg",
3+
"description": "This is a test package for use by functional tests which use packages.",
4+
"author": {
5+
"name": "David Ellingsworth",
6+
"email": "david@desource.org"
7+
},
8+
"main":"js/javascript_entry.js",
9+
"sass":"css/sass_entry.scss"
10+
}

test/functional.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1972,5 +1972,22 @@ module.exports = {
19721972
});
19731973
});
19741974
});
1975+
1976+
describe('Package entrypoint imports', () => {
1977+
it('Import via "sass" package property', (done) => {
1978+
const config = createWebpackConfig('web/build', 'dev');
1979+
1980+
config.setPublicPath('/build');
1981+
config.addAliases({
1982+
lib:path.resolve('./lib')
1983+
});
1984+
config.enableSassLoader();
1985+
config.addStyleEntry('sass', './css/sass_package_import.scss');
1986+
1987+
testSetup.runWebpack(config, () => {
1988+
done();
1989+
})
1990+
});
1991+
});
19751992
});
19761993
});

0 commit comments

Comments
 (0)