Skip to content

Commit 9f9207c

Browse files
committed
feature #729 bumping to css-loader v3 (weaverryan)
This PR was merged into the master branch. Discussion ---------- bumping to css-loader v3 Fixes #728 Breaking changes here: https://github.com/webpack-contrib/css-loader/blob/master/CHANGELOG.md#300-2019-06-11 It doesn't look like anything that affects us directly, though users with customizations could, of course, be affected (or people who are using the `@value` thing). Commits ------- 9f18ba9 bumping to css-loader v3
2 parents 4e6bcf4 + 9f18ba9 commit 9f9207c

File tree

5 files changed

+1701
-1611
lines changed

5 files changed

+1701
-1611
lines changed

lib/loaders/css.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,21 @@ module.exports = {
2222
getLoaders(webpackConfig, useCssModules = false) {
2323
const usePostCssLoader = webpackConfig.usePostCssLoader;
2424

25+
let modulesConfig = false;
26+
if (useCssModules) {
27+
modulesConfig = {
28+
localIdentName: '[local]_[hash:base64:5]',
29+
};
30+
}
31+
2532
const options = {
2633
sourceMap: webpackConfig.useSourceMaps,
2734
// when using @import, how many loaders *before* css-loader should
2835
// be applied to those imports? This defaults to 0. When postcss-loader
2936
// is used, we set it to 1, so that postcss-loader is applied
3037
// to @import resources.
3138
importLoaders: usePostCssLoader ? 1 : 0,
32-
modules: useCssModules,
33-
localIdentName: '[local]_[hash:base64:5]',
39+
modules: modulesConfig
3440
};
3541

3642
const cssLoaders = [

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
"babel-loader": "^8.0.0",
3333
"chalk": "^2.4.1",
3434
"clean-webpack-plugin": "^0.1.19",
35-
"css-loader": "^2.1.1",
35+
"css-loader": "^3.5.2",
3636
"fast-levenshtein": "^2.0.6",
3737
"file-loader": "^1.1.10",
3838
"friendly-errors-webpack-plugin": "^2.0.0-beta.1",
@@ -54,8 +54,8 @@
5454
"yargs-parser": "^12.0.0"
5555
},
5656
"devDependencies": {
57-
"@babel/plugin-transform-react-jsx": "^7.0.0",
5857
"@babel/plugin-proposal-class-properties": "^7.0.0",
58+
"@babel/plugin-transform-react-jsx": "^7.0.0",
5959
"@babel/preset-react": "^7.0.0",
6060
"@babel/preset-typescript": "^7.0.0",
6161
"@vue/babel-helper-vue-jsx-merge-props": "^1.0.0-beta.3",

test/functional.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1749,7 +1749,9 @@ module.exports = {
17491749
config.configureCssLoader(options => {
17501750
// Remove hashes from local ident names
17511751
// since they are not always the same.
1752-
options.localIdentName = '[local]_foo';
1752+
if (options.modules) {
1753+
options.modules.localIdentName = '[local]_foo';
1754+
}
17531755
});
17541756

17551757
// Enable the PostCSS loader so we can use `lang="postcss"`
@@ -2300,16 +2302,16 @@ module.exports = {
23002302
expect(config.outputPath).to.be.a.directory()
23012303
.with.files([
23022304
'entrypoints.json',
2303-
'runtime.d2591ff7.js',
2304-
'main.ceeddab6.js',
2305+
'runtime.e9dea5e6.js',
2306+
'main.00415522.js',
23052307
'manifest.json',
23062308
'symfony_logo.ea1ca6f7.png',
23072309
'symfony_logo_alt.f27119c2.png',
23082310
]);
23092311

23102312
webpackAssert.assertManifestPath(
23112313
'build/main.js',
2312-
'/build/main.ceeddab6.js'
2314+
'/build/main.00415522.js'
23132315
);
23142316
}
23152317

test/loaders/css.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,9 @@ describe('loaders/css', () => {
7171
expect(actualLoaders).to.have.lengthOf(1);
7272
expect(actualLoaders[0].options.foo).to.be.true;
7373
expect(actualLoaders[0].options.url).to.be.false;
74-
expect(actualLoaders[0].options.modules).to.be.true;
74+
expect(actualLoaders[0].options.modules).to.deep.equals({
75+
localIdentName: '[local]_[hash:base64:5]',
76+
});
7577
});
7678

7779
describe('getLoaders() with PostCSS', () => {

0 commit comments

Comments
 (0)