-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(react): add missing style preprocessors when using Vite (#13600)
- Loading branch information
Showing
18 changed files
with
195 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
packages/react/src/generators/application/lib/install-common-dependencies.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import { addDependenciesToPackageJson, Tree } from '@nrwl/devkit'; | ||
import { | ||
lessVersion, | ||
sassVersion, | ||
stylusVersion, | ||
} from '../../../utils/versions'; | ||
import { NormalizedSchema } from '../schema'; | ||
|
||
export function installCommonDependencies( | ||
host: Tree, | ||
options: NormalizedSchema | ||
) { | ||
let devDependencies = null; | ||
|
||
// Vite requires style preprocessors to be installed manually. | ||
// `@nrwl/webpack` installs them automatically for now. | ||
// TODO(jack): Once we clean up webpack we can remove this check | ||
if (options.bundler === 'vite' || options.unitTestRunner === 'vitest') { | ||
switch (options.style) { | ||
case 'scss': | ||
devDependencies = { sass: sassVersion }; | ||
break; | ||
case 'less': | ||
devDependencies = { less: lessVersion }; | ||
break; | ||
case 'styl': | ||
devDependencies = { stylus: stylusVersion }; | ||
break; | ||
} | ||
} | ||
|
||
return devDependencies | ||
? addDependenciesToPackageJson(host, {}, devDependencies) | ||
: function noop() {}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
packages/react/src/generators/library/lib/install-common-dependencies.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import { addDependenciesToPackageJson, Tree } from '@nrwl/devkit'; | ||
import { | ||
lessVersion, | ||
reactDomVersion, | ||
reactVersion, | ||
sassVersion, | ||
stylusVersion, | ||
swcCoreVersion, | ||
} from '../../../utils/versions'; | ||
import { NormalizedSchema } from '../schema'; | ||
|
||
export function installCommonDependencies( | ||
host: Tree, | ||
options: NormalizedSchema | ||
) { | ||
const devDependencies = | ||
options.compiler === 'swc' ? { '@swc/core': swcCoreVersion } : {}; | ||
|
||
// Vite requires style preprocessors to be installed manually. | ||
// `@nrwl/webpack` installs them automatically for now. | ||
// TODO(jack): Once we clean up webpack we can remove this check | ||
if (options.bundler === 'vite' || options.unitTestRunner === 'vitest') { | ||
switch (options.style) { | ||
case 'scss': | ||
devDependencies['sass'] = sassVersion; | ||
break; | ||
case 'less': | ||
devDependencies['less'] = lessVersion; | ||
break; | ||
case 'styl': | ||
devDependencies['stylus'] = stylusVersion; | ||
break; | ||
} | ||
} | ||
|
||
return addDependenciesToPackageJson( | ||
host, | ||
{ | ||
react: reactVersion, | ||
'react-dom': reactDomVersion, | ||
}, | ||
devDependencies | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
export interface VitestGeneratorSchema { | ||
project: string; | ||
uiFramework: 'react' | 'none'; | ||
coverageProvider: 'c8' | 'istanbul'; | ||
inSourceTests?: boolean; | ||
skipViteConfig?: boolean; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
67c7822
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
nx-dev – ./
nx-dev-git-master-nrwl.vercel.app
nx.dev
nx-dev-nrwl.vercel.app
nx-five.vercel.app