Skip to content

Commit f577d39

Browse files
authored
Merge branch 'main' into fb-master
2 parents a75938b + 7519045 commit f577d39

File tree

2 files changed

+38
-5
lines changed

2 files changed

+38
-5
lines changed

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

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ const cssRegex = /\.css$/;
8181
const cssModuleRegex = /\.module\.css$/;
8282
const sassRegex = /\.(scss|sass)$/;
8383
const sassModuleRegex = /\.module\.(scss|sass)$/;
84+
const lessRegex = /\.less$/;
8485

8586
const hasJsxRuntime = (() => {
8687
if (process.env.DISABLE_NEW_JSX_TRANSFORM === 'true') {
@@ -115,7 +116,7 @@ module.exports = function (webpackEnv) {
115116
const shouldUseReactRefresh = env.raw.FAST_REFRESH;
116117

117118
// common function to get style loaders
118-
const getStyleLoaders = (cssOptions, preProcessor) => {
119+
const getStyleLoaders = (cssOptions, preProcessor, preProcessorOptions = {}) => {
119120
const loaders = [
120121
isEnvDevelopment && require.resolve('style-loader'),
121122
isEnvProduction && {
@@ -188,6 +189,7 @@ module.exports = function (webpackEnv) {
188189
{
189190
loader: require.resolve(preProcessor),
190191
options: {
192+
...preProcessorOptions,
191193
sourceMap: true,
192194
},
193195
}
@@ -584,6 +586,35 @@ module.exports = function (webpackEnv) {
584586
'sass-loader'
585587
),
586588
},
589+
// Adds support for Less (using .less extensions)
590+
{
591+
test: lessRegex,
592+
use: getStyleLoaders(
593+
{
594+
importLoaders: 3,
595+
sourceMap: isEnvProduction
596+
? shouldUseSourceMap
597+
: isEnvDevelopment,
598+
modules: {
599+
mode: 'icss',
600+
},
601+
},
602+
'less-loader',
603+
{
604+
lessOptions: {
605+
javascriptEnabled: true,
606+
modifyVars: {
607+
'@primary-color': '#722ed1'
608+
},
609+
}
610+
}
611+
),
612+
// Don't consider CSS imports dead code even if the
613+
// containing package claims to have no side effects.
614+
// Remove this when webpack adds a warning or an error for this.
615+
// See https://github.com/webpack/webpack/issues/6571
616+
sideEffects: true,
617+
},
587618
// "file" loader makes sure those assets get served by WebpackDevServer.
588619
// When you `import` an asset, you get its (virtual) filename.
589620
// In production, they would get copied to the `build` folder.

packages/react-scripts/package.json

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
{
2-
"name": "react-scripts",
3-
"version": "5.0.1",
2+
"name": "@growfin/react-scripts",
3+
"version": "5.0.0",
44
"description": "Configuration and scripts for Create React App.",
55
"repository": {
66
"type": "git",
7-
"url": "https://github.com/facebook/create-react-app.git",
7+
"url": "https://github.com/sinecycle/create-react-app.git",
88
"directory": "packages/react-scripts"
99
},
1010
"license": "MIT",
1111
"engines": {
1212
"node": ">=14.0.0"
1313
},
1414
"bugs": {
15-
"url": "https://github.com/facebook/create-react-app/issues"
15+
"url": "https://github.com/sinecycle/create-react-app/issues"
1616
},
1717
"files": [
1818
"bin",
@@ -53,6 +53,8 @@
5353
"jest": "^27.4.3",
5454
"jest-resolve": "^27.4.2",
5555
"jest-watch-typeahead": "^1.0.0",
56+
"less": "^4.1.2",
57+
"less-loader": "^10.2.0",
5658
"mini-css-extract-plugin": "^2.4.5",
5759
"postcss": "^8.4.4",
5860
"postcss-flexbugs-fixes": "^5.0.2",

0 commit comments

Comments
 (0)