Skip to content

Commit cebf055

Browse files
authored
feat: add CSS module support and use react-jsx transform (#164)
* feat: add CSS module support and use react-jsx transform * Add typescript-plugin-css-modules * Add postcss-preset-mantine
1 parent 96ed975 commit cebf055

File tree

5 files changed

+22
-5
lines changed

5 files changed

+22
-5
lines changed

config/eslintrc.template.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,8 @@ module.exports = ({ tsconfigRootDir, optimizeImports = true }) => ({
136136
'prefer-promise-reject-errors': 'warn',
137137
'prefer-spread': 'warn',
138138
'@typescript-eslint/ban-ts-comment': 'warn',
139+
// Not required with the new JSX transform
140+
'react/react-in-jsx-scope': 'off',
139141
'react/destructuring-assignment': 'off',
140142
'react/jsx-curly-brace-presence': 'warn',
141143
'react/jsx-props-no-spreading': 'off',

config/rspack.config.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,7 @@ module.exports = (webpackEnv, argv) => {
131131
// Explicitly set the host to ipv4 local address to ensure that the dev server is reachable from the host machine: https://github.com/cypress-io/cypress/issues/25397
132132
host: '127.0.0.1',
133133
open: true,
134+
allowedHosts: 'all',
134135
// Needs to be enabled to make SPAs work: https://stackoverflow.com/questions/31945763/how-to-tell-webpack-dev-server-to-serve-index-html-for-any-route
135136
historyApiFallback: historyApiFallback == null ? true : historyApiFallback,
136137
proxy: [
@@ -305,6 +306,7 @@ module.exports = (webpackEnv, argv) => {
305306
postcssOptions: {
306307
plugins: !useTailwind
307308
? [
309+
'postcss-preset-mantine',
308310
'postcss-flexbugs-fixes',
309311
[
310312
'postcss-preset-env',
@@ -323,6 +325,7 @@ module.exports = (webpackEnv, argv) => {
323325
: [
324326
'tailwindcss/nesting',
325327
'tailwindcss',
328+
'postcss-preset-mantine',
326329
'postcss-flexbugs-fixes',
327330
[
328331
'postcss-preset-env',
@@ -373,7 +376,7 @@ module.exports = (webpackEnv, argv) => {
373376
// its runtime that would otherwise be processed through "file" loader.
374377
// Also exclude `html`, `ejs` and `json` extensions so they get processed
375378
// by webpacks internal loaders.
376-
exclude: [/^$/, /\.(js|mjs|jsx|ts|tsx)$/, /\.html$/, /\.ejs$/, /\.json$/],
379+
exclude: [/^$/, /\.(js|mjs|jsx|ts|tsx)$/, /\.module\.css$/, /\.html$/, /\.ejs$/, /\.json$/],
377380
type: 'asset/resource',
378381
},
379382
// ** STOP ** Are you adding a new loader?

config/tsconfig.lenient.template.json

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,20 @@
77
"declaration": true,
88
"declarationMap": true,
99
"moduleResolution": "bundler",
10-
"jsx": "react",
10+
"jsx": "react-jsx",
1111
"allowJs": true,
1212
"experimentalDecorators": true,
1313
"noImplicitAny": false,
1414
"skipLibCheck": true,
1515
"esModuleInterop": false,
1616
"resolveJsonModule": true,
1717
"allowSyntheticDefaultImports": true,
18-
"preserveWatchOutput": true
18+
"preserveWatchOutput": true,
19+
"plugins": [
20+
{
21+
"name": "typescript-plugin-css-modules"
22+
}
23+
]
1924
},
2025
// Old "moduleResolution": "Node" option required for Cypress
2126
// https://github.com/cypress-io/cypress/issues/26308#issuecomment-1663592648

config/tsconfig.template.json

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"declaration": true,
88
"declarationMap": true,
99
"moduleResolution": "bundler",
10-
"jsx": "react",
10+
"jsx": "react-jsx",
1111
"allowJs": true,
1212
"experimentalDecorators": true,
1313
"noImplicitAny": true,
@@ -19,7 +19,12 @@
1919
"strict": true,
2020
"noUncheckedIndexedAccess": true,
2121
"noImplicitReturns": true,
22-
"verbatimModuleSyntax": true
22+
"verbatimModuleSyntax": true,
23+
"plugins": [
24+
{
25+
"name": "typescript-plugin-css-modules"
26+
}
27+
]
2328
},
2429
// Old "moduleResolution": "Node" option required for Cypress
2530
// https://github.com/cypress-io/cypress/issues/26308#issuecomment-1663592648

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@
8585
"postcss-loader": "^8.1.1",
8686
"postcss-normalize": "^13.0.1",
8787
"postcss-preset-env": "^10.1.3",
88+
"postcss-preset-mantine": "^1.18.0",
8889
"prettier": "^3.4.2",
8990
"react-dev-utils": "^12.0.1",
9091
"react-refresh": "^0.18.0",
@@ -97,6 +98,7 @@
9798
"ts-node": "^10.9.2",
9899
"tslib": "~2.8.1",
99100
"typescript": "~5.9.3",
101+
"typescript-plugin-css-modules": "^5.2.0",
100102
"util": "^0.12.5",
101103
"webpack": "^5.97.1",
102104
"yargs": "^17.7.2"

0 commit comments

Comments
 (0)