Skip to content

Commit 4e9c9da

Browse files
ro-savageTimer
authored andcommitted
Change css modules class name to be deterministic and fix licences
1 parent 82d70ee commit 4e9c9da

File tree

5 files changed

+27
-31
lines changed

5 files changed

+27
-31
lines changed

packages/react-scripts/config/webpack.config.dev.js

+20-20
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,26 @@ module.exports = {
241241
},
242242
],
243243
},
244+
// Adds support for CSS Modules (https://github.com/css-modules/css-modules)
245+
// using the extension .module.css
246+
{
247+
test: /\.module\.css$/,
248+
use: [
249+
require.resolve('style-loader'),
250+
{
251+
loader: require.resolve('css-loader'),
252+
options: {
253+
importLoaders: 1,
254+
modules: true,
255+
localIdentName: '[path][name]__[local]',
256+
},
257+
},
258+
{
259+
loader: require.resolve('postcss-loader'),
260+
options: postCSSLoaderOptions,
261+
},
262+
],
263+
},
244264
// "file" loader makes sure those assets get served by WebpackDevServer.
245265
// When you `import` an asset, you get its (virtual) filename.
246266
// In production, they would get copied to the `build` folder.
@@ -259,26 +279,6 @@ module.exports = {
259279
},
260280
],
261281
},
262-
// Adds support for CSS Modules (https://github.com/css-modules/css-modules)
263-
// using the extension .module.css
264-
{
265-
test: /\.module\.css$/,
266-
use: [
267-
require.resolve('style-loader'),
268-
{
269-
loader: require.resolve('css-loader'),
270-
options: {
271-
importLoaders: 1,
272-
modules: true,
273-
localIdentName: '[name]__[local]___[hash:base64:5]',
274-
},
275-
},
276-
{
277-
loader: require.resolve('postcss-loader'),
278-
options: postCSSLoaderOptions,
279-
},
280-
],
281-
},
282282
// ** STOP ** Are you adding a new loader?
283283
// Make sure to add the new loader(s) before the "file" loader.
284284
],

packages/react-scripts/config/webpack.config.prod.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,7 @@ module.exports = {
269269
// Note: this won't work without `new ExtractTextPlugin()` in `plugins`.
270270
},
271271
// Adds support for CSS Modules (https://github.com/css-modules/css-modules)
272-
// using the extension .modules.css
272+
// using the extension .module.css
273273
{
274274
test: /\.module\.css$/,
275275
loader: ExtractTextPlugin.extract(
@@ -289,7 +289,7 @@ module.exports = {
289289
minimize: true,
290290
sourceMap: shouldUseSourceMap,
291291
modules: true,
292-
localIdentName: '[name]__[local]___[hash:base64:5]',
292+
localIdentName: '[path][name]__[local]',
293293
},
294294
},
295295
{

packages/react-scripts/fixtures/kitchensink/integration/webpack.test.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ describe('Integration', () => {
2727
expect(
2828
doc.getElementsByTagName('style')[0].textContent.replace(/\s/g, '')
2929
).to.match(
30-
/\.style-module__cssModulesInclusion___.+\{background:.+;color:.+}/
30+
/.+style-module__cssModulesInclusion+\{background:.+;color:.+}/
3131
);
3232
});
3333

packages/react-scripts/fixtures/kitchensink/src/features/webpack/CssModulesInclusion.js

+2-4
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
/**
22
* Copyright (c) 2015-present, Facebook, Inc.
3-
* All rights reserved.
43
*
5-
* This source code is licensed under the BSD-style license found in the
6-
* LICENSE file in the root directory of this source tree. An additional grant
7-
* of patent rights can be found in the PATENTS file in the same directory.
4+
* This source code is licensed under the MIT license found in the
5+
* LICENSE file in the root directory of this source tree.
86
*/
97

108
import React from 'react';

packages/react-scripts/fixtures/kitchensink/src/features/webpack/CssModulesInclusion.test.js

+2-4
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
/**
22
* Copyright (c) 2015-present, Facebook, Inc.
3-
* All rights reserved.
43
*
5-
* This source code is licensed under the BSD-style license found in the
6-
* LICENSE file in the root directory of this source tree. An additional grant
7-
* of patent rights can be found in the PATENTS file in the same directory.
4+
* This source code is licensed under the MIT license found in the
5+
* LICENSE file in the root directory of this source tree.
86
*/
97

108
import React from 'react';

0 commit comments

Comments
 (0)