@flairjs/webpack-loader 0.0.1-beta.8 → 0.0.1-beta.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +146 -0
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
# @flairjs/webpack-loader
|
|
2
|
+
|
|
3
|
+
Webpack loader for Flair CSS-in-JSX.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @flairjs/webpack-loader
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Usage
|
|
12
|
+
|
|
13
|
+
```js
|
|
14
|
+
// webpack.config.js
|
|
15
|
+
module.exports = {
|
|
16
|
+
module: {
|
|
17
|
+
rules: [
|
|
18
|
+
{
|
|
19
|
+
test: /\.(tsx|jsx)$/,
|
|
20
|
+
use: [
|
|
21
|
+
'@flairjs/webpack-loader'
|
|
22
|
+
],
|
|
23
|
+
exclude: /node_modules/
|
|
24
|
+
}
|
|
25
|
+
]
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
## Configuration
|
|
31
|
+
|
|
32
|
+
```js
|
|
33
|
+
// webpack.config.js
|
|
34
|
+
module.exports = {
|
|
35
|
+
module: {
|
|
36
|
+
rules: [
|
|
37
|
+
{
|
|
38
|
+
test: /\.(tsx|jsx)$/,
|
|
39
|
+
use: [
|
|
40
|
+
'babel-loader',
|
|
41
|
+
{
|
|
42
|
+
loader: '@flairjs/webpack-loader',
|
|
43
|
+
options: {
|
|
44
|
+
// Configuration options
|
|
45
|
+
cssPreprocessor: (css, id) => {
|
|
46
|
+
// Custom CSS preprocessing
|
|
47
|
+
return css
|
|
48
|
+
},
|
|
49
|
+
include: ['src/**/*.{tsx,jsx}'],
|
|
50
|
+
exclude: ['**/*.test.{tsx,jsx}'],
|
|
51
|
+
classNameList: ["className", "class"]
|
|
52
|
+
}
|
|
53
|
+
},
|
|
54
|
+
]
|
|
55
|
+
}
|
|
56
|
+
]
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
### Configuration Options
|
|
62
|
+
|
|
63
|
+
```typescript
|
|
64
|
+
interface FlairJsWebpackLoaderOptions {
|
|
65
|
+
/**
|
|
66
|
+
* Preprocess the extracted CSS before it is passed to lightningcss
|
|
67
|
+
* @experimental
|
|
68
|
+
*/
|
|
69
|
+
cssPreprocessor?: (css: string, id: string) => string
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Files to include (default: all .tsx/.jsx files)
|
|
73
|
+
*/
|
|
74
|
+
include?: string | string[]
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Files to exclude (default: node_modules)
|
|
78
|
+
*/
|
|
79
|
+
exclude?: string | string[]
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* Override the default theme file content
|
|
83
|
+
*/
|
|
84
|
+
buildThemeFile?: (theme: FlairThemeConfig) => string
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* List of class names used in the project. Supports regex.
|
|
88
|
+
*/
|
|
89
|
+
classNameList?: string[]
|
|
90
|
+
}
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
## CSS Handling
|
|
94
|
+
|
|
95
|
+
Ensure your webpack configuration can handle CSS files:
|
|
96
|
+
|
|
97
|
+
```js
|
|
98
|
+
// webpack.config.js
|
|
99
|
+
module.exports = {
|
|
100
|
+
module: {
|
|
101
|
+
rules: [
|
|
102
|
+
// Flair loader
|
|
103
|
+
{
|
|
104
|
+
test: /\.(tsx|jsx)$/,
|
|
105
|
+
use: ['@flairjs/webpack-loader']
|
|
106
|
+
},
|
|
107
|
+
// CSS loader for generated styles
|
|
108
|
+
{
|
|
109
|
+
test: /\.css$/,
|
|
110
|
+
use: ['style-loader', 'css-loader']
|
|
111
|
+
}
|
|
112
|
+
]
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
|
|
118
|
+
## Theme Integration
|
|
119
|
+
|
|
120
|
+
Create a `flair.theme.ts` in your project root:
|
|
121
|
+
|
|
122
|
+
```typescript
|
|
123
|
+
// flair.theme.ts
|
|
124
|
+
import { defineConfig } from '@flairjs/client'
|
|
125
|
+
|
|
126
|
+
export default defineConfig({
|
|
127
|
+
tokens: {
|
|
128
|
+
colors: {
|
|
129
|
+
primary: '#3b82f6',
|
|
130
|
+
secondary: '#64748b'
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
})
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
Import the theme in your entry file:
|
|
137
|
+
|
|
138
|
+
```js
|
|
139
|
+
// src/index.js
|
|
140
|
+
import '@flairjs/client/theme.css'
|
|
141
|
+
import './App'
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
## License
|
|
145
|
+
|
|
146
|
+
MIT
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@flairjs/webpack-loader",
|
|
3
|
-
"version": "0.0.1-beta.
|
|
3
|
+
"version": "0.0.1-beta.9",
|
|
4
4
|
"main": "./dist/cjs/index.js",
|
|
5
5
|
"module": "./dist/esm/index.js",
|
|
6
6
|
"types": "./dist/types/index.d.ts",
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
},
|
|
14
14
|
"peerDependencies": {
|
|
15
15
|
"webpack": ">=5.0.0",
|
|
16
|
-
"@flairjs/core": "0.0.1-beta.
|
|
16
|
+
"@flairjs/core": "0.0.1-beta.8"
|
|
17
17
|
},
|
|
18
18
|
"devDependencies": {
|
|
19
19
|
"@biomejs/biome": "^2.2.4",
|
|
@@ -23,8 +23,8 @@
|
|
|
23
23
|
"rolldown": "1.0.0-beta.37",
|
|
24
24
|
"typescript": "^5.8.2",
|
|
25
25
|
"webpack": "^5.101.0",
|
|
26
|
-
"@flairjs/bundler-shared": "0.0.1-beta.
|
|
27
|
-
"@flairjs/core": "0.0.1-beta.
|
|
26
|
+
"@flairjs/bundler-shared": "0.0.1-beta.13",
|
|
27
|
+
"@flairjs/core": "0.0.1-beta.8"
|
|
28
28
|
},
|
|
29
29
|
"dependencies": {
|
|
30
30
|
"esbuild": "^0.25.10",
|