styles-config 2.0.0-alpha.1

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2018 Matthew Dean
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,325 @@
1
+ # styles-config
2
+
3
+ A general-purpose configuration system for styling frameworks including Jess, Less, Sass, Tailwind, and more.
4
+
5
+ ## Overview
6
+
7
+ `styles-config` provides a unified configuration format and loading system that works across multiple CSS preprocessors and styling frameworks. It allows you to define configuration once and use it with different tools, or maintain separate configurations for different frameworks.
8
+
9
+ ## Features
10
+
11
+ - **Universal Configuration Format**: Single configuration structure that works with multiple styling frameworks
12
+ - **Framework-Specific Options**: Support for Less, Sass, Jess, and other framework-specific settings
13
+ - **Per-File Configuration**: Override settings for specific input or output files using paths or glob patterns
14
+ - **Flexible Loading**: Supports multiple config file formats (JSON, YAML, JavaScript, TypeScript)
15
+ - **Smart Merging**: Combines compile, language, input, and output settings intelligently
16
+
17
+ ## Installation
18
+
19
+ ```bash
20
+ npm install styles-config
21
+ # or
22
+ pnpm add styles-config
23
+ # or
24
+ yarn add styles-config
25
+ ```
26
+
27
+ ## Configuration File Format
28
+
29
+ Create a configuration file in your project root. Supported file names:
30
+
31
+ - `styles.config.{c,m}?{js,ts}` e.g. `styles.config.ts`
32
+
33
+ ### Configuration Structure
34
+
35
+ ```typescript
36
+ interface StylesConfig {
37
+ compile?: {
38
+ plugins?: PluginInterface[];
39
+ searchPaths?: string[];
40
+ enableJavaScript?: boolean;
41
+ mathMode?: 'always' | 'parens-division' | 'parens' | 'strict';
42
+ unitMode?: 'loose' | 'strict';
43
+ equalityMode?: 'coerce' | 'strict';
44
+ };
45
+ input?: InputOptions | InputOptions[];
46
+ output?: OutputOptions | OutputOptions[];
47
+ language?: {
48
+ less?: LessOptions;
49
+ scss?: Record<string, any>;
50
+ css?: Record<string, any>;
51
+ jess?: Record<string, any>;
52
+ [key: string]: any;
53
+ };
54
+ }
55
+
56
+ interface InputOptions {
57
+ file?: string; // Path or glob pattern to match input files
58
+ mathMode?: MathMode;
59
+ unitMode?: UnitMode;
60
+ equalityMode?: EqualityMode;
61
+ // ... any compile or language options to override
62
+ }
63
+
64
+ interface OutputOptions {
65
+ file?: string; // Path or glob pattern to match output files
66
+ collapseNesting?: boolean;
67
+ compress?: boolean;
68
+ sourceMap?: boolean;
69
+ // ... any output options to override
70
+ }
71
+ ```
72
+
73
+ ### Example Configuration
74
+
75
+ ```javascript
76
+ // styles.config.js
77
+ export default {
78
+ compile: {
79
+ mathMode: 'parens-division',
80
+ unitMode: 'loose',
81
+ equalityMode: 'coerce',
82
+ searchPaths: ['./src/styles', './node_modules']
83
+ },
84
+ input: [
85
+ // Default input options (no file pattern)
86
+ { leakyRules: false },
87
+ // Override for legacy files
88
+ { file: 'legacy/**/*.less', mathMode: 'always', leakyRules: true }
89
+ ],
90
+ output: [
91
+ // Default output options
92
+ { sourceMap: true, compress: false },
93
+ // Override for minified builds
94
+ { file: '**/*.min.css', compress: true, sourceMap: false }
95
+ ],
96
+ language: {
97
+ less: {
98
+ strictImports: false
99
+ },
100
+ scss: {
101
+ precision: 10,
102
+ outputStyle: 'expanded'
103
+ }
104
+ }
105
+ };
106
+ ```
107
+
108
+ ## Usage
109
+
110
+ ### Loading Configuration
111
+
112
+ ```typescript
113
+ import { loadConfig, loadConfigSync } from 'styles-config';
114
+
115
+ // Async loading
116
+ const config = await loadConfig('/path/to/project');
117
+
118
+ // Sync loading
119
+ const config = loadConfigSync('/path/to/project');
120
+ ```
121
+
122
+ ### Getting Merged Options
123
+
124
+ Use the `getOptions` function to get merged options for a specific file:
125
+
126
+ ```typescript
127
+ import { loadConfigSync, getOptions } from 'styles-config';
128
+
129
+ const config = loadConfigSync();
130
+
131
+ // Language is inferred from the input file extension
132
+ const options = getOptions(config, {
133
+ input: 'src/styles/main.less',
134
+ output: 'dist/main.css'
135
+ });
136
+
137
+ // Or explicitly specify the language
138
+ const options = getOptions(config, {
139
+ language: 'less',
140
+ input: 'src/styles/main.less',
141
+ output: 'dist/main.css'
142
+ });
143
+
144
+ // Get default options for a language (no file matching)
145
+ const defaults = getOptions(config, { language: 'scss' });
146
+ ```
147
+
148
+ ### How Options Are Merged
149
+
150
+ Options are merged in this priority order (later wins):
151
+
152
+ 1. **Compile options** (`compile.*`) - base settings
153
+ 2. **Language-specific options** (`language.less`, etc.) - language defaults
154
+ 3. **Matched input options** (`input[]` entries matching the input file)
155
+ 4. **Matched output options** (`output[]` entries matching the output file)
156
+
157
+ For example, with this config:
158
+
159
+ ```javascript
160
+ {
161
+ compile: { mathMode: 'parens-division' },
162
+ input: [
163
+ { leakyRules: false },
164
+ { file: 'legacy/**/*.less', mathMode: 'always', leakyRules: true }
165
+ ],
166
+ output: [
167
+ { compress: false },
168
+ { file: '**/*.min.css', compress: true }
169
+ ],
170
+ language: {
171
+ less: { collapseNesting: true }
172
+ }
173
+ }
174
+ ```
175
+
176
+ Calling `getOptions(config, { input: 'legacy/old.less', output: 'dist/old.min.css' })`:
177
+ - `mathMode: 'always'` - from matched input (overrides compile)
178
+ - `leakyRules: true` - from matched input (overrides default input)
179
+ - `collapseNesting: true` - from language.less
180
+ - `compress: true` - from matched output (overrides default output)
181
+
182
+ ### File Matching
183
+
184
+ Both `input` and `output` options support file matching via the `file` property:
185
+
186
+ - **Exact paths**: `src/styles/main.less`
187
+ - **Relative paths**: `main.less` (matches any file with that basename)
188
+ - **Glob patterns**: `legacy/**/*.less`, `**/*.min.css`
189
+
190
+ Entries without a `file` property serve as defaults and always apply.
191
+
192
+ ## Use Cases
193
+
194
+ ### Single Framework Projects
195
+
196
+ ```javascript
197
+ // styles.config.js
198
+ export default {
199
+ output: {
200
+ sourceMap: true,
201
+ compress: process.env.NODE_ENV === 'production'
202
+ },
203
+ language: {
204
+ less: {
205
+ leakyRules: false
206
+ }
207
+ }
208
+ };
209
+ ```
210
+
211
+ ### Multi-Framework Projects
212
+
213
+ ```javascript
214
+ // styles.config.js
215
+ export default {
216
+ compile: {
217
+ mathMode: 'parens-division',
218
+ unitMode: 'loose'
219
+ },
220
+ output: {
221
+ sourceMap: true,
222
+ compress: false
223
+ },
224
+ language: {
225
+ less: {
226
+ strictImports: 'error'
227
+ },
228
+ scss: {
229
+ precision: 10,
230
+ outputStyle: 'expanded'
231
+ }
232
+ }
233
+ };
234
+ ```
235
+
236
+ ### Per-File Overrides
237
+
238
+ ```javascript
239
+ // styles.config.js
240
+ export default {
241
+ compile: {
242
+ mathMode: 'parens-division'
243
+ },
244
+ input: [
245
+ // Modern files use strict math
246
+ { file: 'src/modern/**/*.less', mathMode: 'strict' },
247
+ // Legacy files need legacy behavior
248
+ { file: 'src/legacy/**/*.less', mathMode: 'always', leakyRules: true }
249
+ ],
250
+ output: [
251
+ // Development builds
252
+ { sourceMap: true, compress: false },
253
+ // Production minified builds
254
+ { file: 'dist/**/*.min.css', compress: true, sourceMap: false }
255
+ ]
256
+ };
257
+ ```
258
+
259
+ ### Framework-Agnostic Tools
260
+
261
+ Build tools can use the configuration format to support multiple styling frameworks:
262
+
263
+ ```typescript
264
+ import { loadConfig, getOptions } from 'styles-config';
265
+
266
+ const config = await loadConfig(projectRoot);
267
+
268
+ // Options are automatically merged based on input/output files
269
+ // Language is inferred from the input extension
270
+ const options = getOptions(config, {
271
+ input: file,
272
+ output: outputPath
273
+ });
274
+ ```
275
+
276
+ ## API Reference
277
+
278
+ ### `loadConfig(searchFrom?: string): Promise<StylesConfig | null>`
279
+
280
+ Asynchronously loads configuration from the file system, searching from the given directory up to the root.
281
+
282
+ ### `loadConfigSync(searchFrom?: string): StylesConfig`
283
+
284
+ Synchronously loads configuration from the file system.
285
+
286
+ ### `loadConfigFromPath(filePath: string): Promise<StylesConfig | null>`
287
+
288
+ Loads configuration from a specific file path (async).
289
+
290
+ ### `loadConfigFromPathSync(filePath: string): StylesConfig`
291
+
292
+ Loads configuration from a specific file path (sync).
293
+
294
+ ### `getOptions(config: StylesConfig, params?: GetOptionsParams): Record<string, any>`
295
+
296
+ Merges configuration based on language, input file, and output file.
297
+
298
+ **Parameters:**
299
+ - `config`: The styles configuration object
300
+ - `params.language`: Language key (e.g., 'less', 'scss'). Inferred from input extension if not provided.
301
+ - `params.input`: Input file path for matching input options
302
+ - `params.output`: Output file path for matching output options
303
+
304
+ **Returns:** Merged options object
305
+
306
+ ## Supported Frameworks
307
+
308
+ - **Jess** - JavaScript Enhanced Style Sheets
309
+ - **Less** - The dynamic stylesheet language
310
+ - **Sass/SCSS** - Syntactically Awesome Style Sheets
311
+ - **Tailwind CSS** - Utility-first CSS framework (via plugins)
312
+ - **PostCSS** - Tool for transforming CSS with JavaScript
313
+ - **Any custom framework** - Extensible to support any styling tool
314
+
315
+ ## Contributing
316
+
317
+ This package is designed to be extensible. To add support for a new framework:
318
+
319
+ 1. Add the framework's options type to `src/types.ts`
320
+ 2. Add the extension mapping in `src/options.ts` if needed
321
+ 3. Update the documentation
322
+
323
+ ## License
324
+
325
+ MIT
@@ -0,0 +1,6 @@
1
+ import baseConfig from '../_shared/eslint.config.mjs';
2
+
3
+ export default [
4
+ ...baseConfig
5
+ ];
6
+
package/lib/index.d.ts ADDED
@@ -0,0 +1,3 @@
1
+ export * from './types.js';
2
+ export * from './loader.js';
3
+ export * from './options.js';
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,cAAc,UAAU,CAAC;AACzB,cAAc,WAAW,CAAC"}
package/lib/index.js ADDED
@@ -0,0 +1,4 @@
1
+ export * from './types.js';
2
+ export * from './loader.js';
3
+ export * from './options.js';
4
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC"}
@@ -0,0 +1,34 @@
1
+ import type { StylesConfig } from './types.js';
2
+ export interface LoadedConfigMeta {
3
+ config: StylesConfig;
4
+ configFilePath?: string;
5
+ }
6
+ /**
7
+ * Load styles configuration from the file system (async)
8
+ * @param searchFrom - Directory to search from (defaults to process.cwd())
9
+ * @returns Configuration object or null if not found
10
+ */
11
+ export declare function loadConfig(searchFrom?: string): Promise<StylesConfig | null>;
12
+ /**
13
+ * Load styles configuration from the file system (sync)
14
+ * @param searchFrom - Directory to search from (defaults to process.cwd())
15
+ * @returns Configuration object or empty object if not found
16
+ */
17
+ export declare function loadConfigSync(searchFrom?: string): StylesConfig;
18
+ /**
19
+ * Load styles configuration with metadata (sync).
20
+ * Includes config file path when a config file is discovered.
21
+ */
22
+ export declare function loadConfigSyncWithMeta(searchFrom?: string): LoadedConfigMeta;
23
+ /**
24
+ * Load styles configuration from a specific file path (async)
25
+ * @param filePath - Path to the config file
26
+ * @returns Configuration object or null if not found
27
+ */
28
+ export declare function loadConfigFromPath(filePath: string): Promise<StylesConfig | null>;
29
+ /**
30
+ * Load styles configuration from a specific file path (sync)
31
+ * @param filePath - Path to the config file
32
+ * @returns Configuration object or empty object if not found
33
+ */
34
+ export declare function loadConfigFromPathSync(filePath: string): StylesConfig;
@@ -0,0 +1 @@
1
+ {"version":3,"file":"loader.d.ts","sourceRoot":"","sources":["../src/loader.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AA4C5C;;;;GAIG;AACH,wBAAsB,UAAU,CAAC,UAAU,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,GAAG,IAAI,CAAC,CAGlF;AAED;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,UAAU,CAAC,EAAE,MAAM,GAAG,YAAY,CAGhE;AAED;;;;GAIG;AACH,wBAAsB,kBAAkB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,GAAG,IAAI,CAAC,CAGvF;AAED;;;;GAIG;AACH,wBAAgB,sBAAsB,CAAC,QAAQ,EAAE,MAAM,GAAG,YAAY,CAGrE"}
package/lib/loader.js ADDED
@@ -0,0 +1,99 @@
1
+ import { cosmiconfig, cosmiconfigSync, defaultLoadersSync } from 'cosmiconfig';
2
+ const explorer = cosmiconfig('styles', {
3
+ searchPlaces: [
4
+ 'styles.config.ts',
5
+ 'styles.config.js',
6
+ 'styles.config.mts',
7
+ 'styles.config.mjs',
8
+ 'styles.config.cjs',
9
+ 'styles.config.cts'
10
+ ],
11
+ loaders: {
12
+ // eslint-disable-next-line @typescript-eslint/naming-convention
13
+ '.mts': defaultLoadersSync['.ts'],
14
+ // eslint-disable-next-line @typescript-eslint/naming-convention
15
+ '.cts': defaultLoadersSync['.ts'],
16
+ // eslint-disable-next-line @typescript-eslint/naming-convention
17
+ '.mjs': defaultLoadersSync['.js'],
18
+ // eslint-disable-next-line @typescript-eslint/naming-convention
19
+ '.cjs': defaultLoadersSync['.cjs']
20
+ }
21
+ });
22
+ const explorerSync = cosmiconfigSync('styles', {
23
+ searchPlaces: [
24
+ 'styles.config.ts',
25
+ 'styles.config.js',
26
+ 'styles.config.mts',
27
+ 'styles.config.mjs',
28
+ 'styles.config.cjs',
29
+ 'styles.config.cts'
30
+ ],
31
+ loaders: {
32
+ // eslint-disable-next-line @typescript-eslint/naming-convention
33
+ '.mts': defaultLoadersSync['.ts'],
34
+ // eslint-disable-next-line @typescript-eslint/naming-convention
35
+ '.cts': defaultLoadersSync['.ts'],
36
+ // eslint-disable-next-line @typescript-eslint/naming-convention
37
+ '.mjs': defaultLoadersSync['.js'],
38
+ // eslint-disable-next-line @typescript-eslint/naming-convention
39
+ '.cjs': defaultLoadersSync['.cjs']
40
+ }
41
+ });
42
+ /**
43
+ * Load styles configuration from the file system (async)
44
+ * @param searchFrom - Directory to search from (defaults to process.cwd())
45
+ * @returns Configuration object or null if not found
46
+ */
47
+ export async function loadConfig(searchFrom) {
48
+ const result = await explorer.search(searchFrom);
49
+ return result?.config ? normalizeConfig(result.config) : null;
50
+ }
51
+ /**
52
+ * Load styles configuration from the file system (sync)
53
+ * @param searchFrom - Directory to search from (defaults to process.cwd())
54
+ * @returns Configuration object or empty object if not found
55
+ */
56
+ export function loadConfigSync(searchFrom) {
57
+ const result = explorerSync.search(searchFrom);
58
+ return result?.config ? normalizeConfig(result.config) : {};
59
+ }
60
+ /**
61
+ * Load styles configuration with metadata (sync).
62
+ * Includes config file path when a config file is discovered.
63
+ */
64
+ export function loadConfigSyncWithMeta(searchFrom) {
65
+ const result = explorerSync.search(searchFrom);
66
+ return {
67
+ config: result?.config ? normalizeConfig(result.config) : {},
68
+ configFilePath: result?.filepath
69
+ };
70
+ }
71
+ /**
72
+ * Load styles configuration from a specific file path (async)
73
+ * @param filePath - Path to the config file
74
+ * @returns Configuration object or null if not found
75
+ */
76
+ export async function loadConfigFromPath(filePath) {
77
+ const result = await explorer.load(filePath);
78
+ return result?.config ? normalizeConfig(result.config) : null;
79
+ }
80
+ /**
81
+ * Load styles configuration from a specific file path (sync)
82
+ * @param filePath - Path to the config file
83
+ * @returns Configuration object or empty object if not found
84
+ */
85
+ export function loadConfigFromPathSync(filePath) {
86
+ const result = explorerSync.load(filePath);
87
+ return result?.config ? normalizeConfig(result.config) : {};
88
+ }
89
+ /**
90
+ * Normalize config object - handle default exports and ensure proper type
91
+ */
92
+ function normalizeConfig(config) {
93
+ // Handle default export (common in ES modules)
94
+ if (typeof config === 'object' && config !== null && 'default' in config) {
95
+ return config.default;
96
+ }
97
+ return config;
98
+ }
99
+ //# sourceMappingURL=loader.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"loader.js","sourceRoot":"","sources":["../src/loader.ts"],"names":[],"mappings":"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"}
@@ -0,0 +1,49 @@
1
+ import type { StylesConfig } from './types.js';
2
+ /**
3
+ * Options for retrieving merged configuration
4
+ */
5
+ export interface GetOptionsParams {
6
+ /**
7
+ * Language key to get options for (e.g., 'less', 'scss', 'jess').
8
+ * If omitted but `input` is provided, language is inferred from the file extension.
9
+ */
10
+ language?: string;
11
+ /**
12
+ * Input file path to match against input options.
13
+ * Also used to infer language if `language` is not specified.
14
+ */
15
+ input?: string;
16
+ /**
17
+ * Output file path to match against output options
18
+ */
19
+ output?: string;
20
+ }
21
+ /**
22
+ * Get merged options by combining compile, language, input, and output settings.
23
+ *
24
+ * Merge priority (later wins):
25
+ * 1. compile options (base)
26
+ * 2. language-specific options (inferred from input extension or explicitly specified)
27
+ * 3. matched input options (if input path provided and matches)
28
+ * 4. matched output options (if output path provided and matches)
29
+ *
30
+ * @param config - The styles configuration object
31
+ * @param params - Options specifying language, input file, and output file
32
+ * @returns Merged options object
33
+ *
34
+ * @example
35
+ * // Get Less options for a specific input/output (language inferred from .less extension)
36
+ * const options = getOptions(config, {
37
+ * input: 'src/styles/main.less',
38
+ * output: 'dist/main.css'
39
+ * });
40
+ *
41
+ * @example
42
+ * // Explicitly specify language
43
+ * const options = getOptions(config, { language: 'less' });
44
+ *
45
+ * @example
46
+ * // Get base options without language-specific settings
47
+ * const options = getOptions(config);
48
+ */
49
+ export declare function getOptions(config?: StylesConfig, params?: GetOptionsParams): Record<string, any>;
@@ -0,0 +1 @@
1
+ {"version":3,"file":"options.d.ts","sourceRoot":"","sources":["../src/options.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAEzD;;GAEG;AACH,wBAAgB,cAAc,CAAC,MAAM,GAAE,YAAiB,GAAG,WAAW,CAcrE;AACD;;GAEG;AACH,wBAAgB,cAAc,CAAC,MAAM,GAAE,YAAiB,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAc7E;AAED;;GAEG;AACH,wBAAgB,cAAc,CAAC,MAAM,GAAE,YAAiB,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAc7E"}