Skip to content
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

bumping to css-loader v3 #729

Merged
merged 1 commit into from
Apr 17, 2020
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
10 changes: 8 additions & 2 deletions lib/loaders/css.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,21 @@ module.exports = {
getLoaders(webpackConfig, useCssModules = false) {
const usePostCssLoader = webpackConfig.usePostCssLoader;

let modulesConfig = false;
if (useCssModules) {
modulesConfig = {
localIdentName: '[local]_[hash:base64:5]',
};
}

const options = {
sourceMap: webpackConfig.useSourceMaps,
// when using @import, how many loaders *before* css-loader should
// be applied to those imports? This defaults to 0. When postcss-loader
// is used, we set it to 1, so that postcss-loader is applied
// to @import resources.
importLoaders: usePostCssLoader ? 1 : 0,
modules: useCssModules,
localIdentName: '[local]_[hash:base64:5]',
modules: modulesConfig
};

const cssLoaders = [
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
"babel-loader": "^8.0.0",
"chalk": "^2.4.1",
"clean-webpack-plugin": "^0.1.19",
"css-loader": "^2.1.1",
"css-loader": "^3.5.2",
"fast-levenshtein": "^2.0.6",
"file-loader": "^1.1.10",
"friendly-errors-webpack-plugin": "^2.0.0-beta.1",
Expand All @@ -54,8 +54,8 @@
"yargs-parser": "^12.0.0"
},
"devDependencies": {
"@babel/plugin-transform-react-jsx": "^7.0.0",
"@babel/plugin-proposal-class-properties": "^7.0.0",
"@babel/plugin-transform-react-jsx": "^7.0.0",
"@babel/preset-react": "^7.0.0",
"@babel/preset-typescript": "^7.0.0",
"@vue/babel-helper-vue-jsx-merge-props": "^1.0.0-beta.3",
Expand Down
10 changes: 6 additions & 4 deletions test/functional.js
Original file line number Diff line number Diff line change
Expand Up @@ -1749,7 +1749,9 @@ module.exports = {
config.configureCssLoader(options => {
// Remove hashes from local ident names
// since they are not always the same.
options.localIdentName = '[local]_foo';
if (options.modules) {
options.modules.localIdentName = '[local]_foo';
}
});

// Enable the PostCSS loader so we can use `lang="postcss"`
Expand Down Expand Up @@ -2300,16 +2302,16 @@ module.exports = {
expect(config.outputPath).to.be.a.directory()
.with.files([
'entrypoints.json',
'runtime.d2591ff7.js',
'main.ceeddab6.js',
'runtime.e9dea5e6.js',
'main.00415522.js',
'manifest.json',
'symfony_logo.ea1ca6f7.png',
'symfony_logo_alt.f27119c2.png',
]);

webpackAssert.assertManifestPath(
'build/main.js',
'/build/main.ceeddab6.js'
'/build/main.00415522.js'
);
}

Expand Down
4 changes: 3 additions & 1 deletion test/loaders/css.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,9 @@ describe('loaders/css', () => {
expect(actualLoaders).to.have.lengthOf(1);
expect(actualLoaders[0].options.foo).to.be.true;
expect(actualLoaders[0].options.url).to.be.false;
expect(actualLoaders[0].options.modules).to.be.true;
expect(actualLoaders[0].options.modules).to.deep.equals({
localIdentName: '[local]_[hash:base64:5]',
});
});

describe('getLoaders() with PostCSS', () => {
Expand Down
Loading