@visulima/rollup-plugin-css 1.0.0-alpha.30 → 1.0.0-alpha.32
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/CHANGELOG.md +18 -0
- package/dist/css-modules-types.d.ts +38 -0
- package/dist/css-plugin.d.ts +44 -0
- package/dist/index.d.ts +40 -19
- package/dist/loaders/less/importer.d.ts +2 -0
- package/dist/loaders/less/index.d.ts +36 -15
- package/dist/loaders/less/types.d.ts +24 -0
- package/dist/loaders/lightningcss.d.ts +13 -15
- package/dist/loaders/loader-manager.d.ts +78 -0
- package/dist/loaders/postcss/constants.d.ts +20 -0
- package/dist/loaders/postcss/icss/index.d.ts +8 -0
- package/dist/loaders/postcss/icss/load.d.ts +5 -0
- package/dist/loaders/postcss/icss/resolve.d.ts +6 -0
- package/dist/loaders/postcss/import/apply-conditions.d.ts +10 -0
- package/dist/loaders/postcss/import/apply-raws.d.ts +3 -0
- package/dist/loaders/postcss/import/apply-styles.d.ts +10 -0
- package/dist/loaders/postcss/import/constants.d.ts +12 -0
- package/dist/loaders/postcss/import/import-resolve.d.ts +3 -0
- package/dist/loaders/postcss/import/index.d.ts +12 -0
- package/dist/loaders/postcss/import/parser/parse-at-import.d.ts +9 -0
- package/dist/loaders/postcss/import/parser/parse-styles.d.ts +6 -0
- package/dist/loaders/postcss/import/parser/parse-stylesheet.d.ts +10 -0
- package/dist/loaders/postcss/import/types.d.ts +95 -0
- package/dist/loaders/postcss/import/utils/base64-encoded-import.d.ts +3 -0
- package/dist/loaders/postcss/import/utils/data-url.d.ts +2 -0
- package/dist/loaders/postcss/import/utils/format-import-prelude.d.ts +2 -0
- package/dist/loaders/postcss/import/utils/load-content.d.ts +2 -0
- package/dist/loaders/postcss/import/utils/process-content.d.ts +4 -0
- package/dist/loaders/postcss/import/utils/statement.d.ts +6 -0
- package/dist/loaders/postcss/index.d.ts +27 -15
- package/dist/loaders/postcss/load-config.d.ts +6 -0
- package/dist/loaders/postcss/modules/generate.d.ts +11 -0
- package/dist/loaders/postcss/modules/index.d.ts +35 -0
- package/dist/loaders/postcss/noop.d.ts +22 -0
- package/dist/loaders/postcss/url/generate.d.ts +2 -0
- package/dist/loaders/postcss/url/index.d.ts +46 -0
- package/dist/loaders/postcss/url/inline.d.ts +20 -0
- package/dist/loaders/postcss/url/url-resolve.d.ts +12 -0
- package/dist/loaders/postcss/url/utils.d.ts +4 -0
- package/dist/loaders/sass/index.d.ts +4 -16
- package/dist/loaders/sass/modern/importer.d.ts +3 -0
- package/dist/loaders/sass/types.d.ts +20 -0
- package/dist/loaders/sass/utils/get-sass-compiler.d.ts +8 -0
- package/dist/loaders/sass/utils/get-sass-options.d.ts +7 -0
- package/dist/loaders/sass/utils/normalize-source-map.d.ts +3 -0
- package/dist/loaders/sass/utils/resolve-syntax.d.ts +2 -0
- package/dist/loaders/sass/utils/sass-error-factory.d.ts +15 -0
- package/dist/loaders/sourcemap.d.ts +24 -15
- package/dist/loaders/stylus/index.d.ts +7 -16
- package/dist/loaders/stylus/types.d.ts +87 -0
- package/dist/loaders/tailwindcss-oxide.d.ts +5 -15
- package/dist/loaders/types.d.ts +102 -0
- package/dist/loaders/utils/ensure-auto-modules.d.ts +39 -0
- package/dist/loaders/utils/match-file.d.ts +32 -0
- package/dist/minifiers/cssnano.d.ts +30 -15
- package/dist/minifiers/lightningcss.d.ts +29 -15
- package/dist/minifiers/types.d.ts +64 -0
- package/dist/types.d.ts +224 -0
- package/dist/utils/array-fmt.d.ts +18 -0
- package/dist/utils/concat.d.ts +34 -0
- package/dist/utils/generate-js-exports.d.ts +78 -0
- package/dist/utils/index.d.ts +9 -72
- package/dist/utils/load-module.d.ts +3 -0
- package/dist/utils/options.d.ts +155 -0
- package/dist/utils/resolve.d.ts +35 -0
- package/dist/utils/safe-id.d.ts +23 -0
- package/dist/utils/sourcemap.d.ts +42 -0
- package/dist/utils/url.d.ts +8 -0
- package/package.json +5 -5
- package/dist/packem_shared/types-B7InbTq8.d.ts +0 -206
|
@@ -1,16 +1,28 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
1
|
+
import type { InternalStyleOptions } from "../../types.d.ts";
|
|
2
|
+
import type { Loader } from "../types.d.ts";
|
|
3
|
+
/**
|
|
4
|
+
* PostCSS loader for processing CSS with PostCSS plugins and CSS modules.
|
|
5
|
+
*
|
|
6
|
+
* This loader provides comprehensive CSS processing including:
|
|
7
|
+
* - PostCSS plugin pipeline execution
|
|
8
|
+
* - CSS modules support with automatic detection
|
|
9
|
+
* - Import resolution and dependency tracking
|
|
10
|
+
* - URL processing and asset handling
|
|
11
|
+
* - Source map generation and transformation
|
|
12
|
+
* - JavaScript code generation for CSS injection
|
|
13
|
+
*
|
|
14
|
+
* The loader always processes files since PostCSS can handle any CSS content
|
|
15
|
+
* and provides the base transformation layer for other preprocessors.
|
|
16
|
+
* @example
|
|
17
|
+
* ```typescript
|
|
18
|
+
* // CSS Modules processing
|
|
19
|
+
* // Input: .button { color: red; }
|
|
20
|
+
* // Output: JavaScript with hashed class names and CSS injection
|
|
21
|
+
*
|
|
22
|
+
* // Regular CSS processing
|
|
23
|
+
* // Input: @import "normalize.css"; .app { color: blue; }
|
|
24
|
+
* // Output: Resolved imports and processed CSS
|
|
25
|
+
* ```
|
|
26
|
+
*/
|
|
14
27
|
declare const loader: Loader<NonNullable<InternalStyleOptions["postcss"]>>;
|
|
15
|
-
|
|
16
|
-
export { loader as default };
|
|
28
|
+
export default loader;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { Environment } from "@visulima/packem-share/types";
|
|
2
|
+
import type { RollupLogger } from "@visulima/packem-share/utils";
|
|
3
|
+
import type { Result } from "postcss-load-config";
|
|
4
|
+
import type { PostCSSConfigLoaderOptions } from "../../types.d.ts";
|
|
5
|
+
declare const loadConfig: (id: string, cwd: string, environment: Environment, logger: RollupLogger, options?: PostCSSConfigLoaderOptions | false) => Promise<Result>;
|
|
6
|
+
export default loadConfig;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* For reference, postcss-modules's default:
|
|
3
|
+
* https://github.com/madyankin/postcss-modules/blob/v6.0.0/src/scoping.js#L41
|
|
4
|
+
*
|
|
5
|
+
* FYI LightningCSS recommends hash first for grid compatibility,
|
|
6
|
+
* https://github.com/parcel-bundler/lightningcss/blob/v1.23.0/website/pages/css-modules.md?plain=1#L237-L238
|
|
7
|
+
*
|
|
8
|
+
* but PostCSS CSS Modules doesn't seem to transform Grid names
|
|
9
|
+
*/
|
|
10
|
+
declare const generate: (placeholder?: string) => (local: string, file: string, css: string) => string;
|
|
11
|
+
export default generate;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { Plugin } from "postcss";
|
|
2
|
+
import type Processor from "postcss/lib/processor";
|
|
3
|
+
import type { AutoModules } from "../../../types.d.ts";
|
|
4
|
+
declare const modules: (options: ModulesOptions) => (Plugin | Processor)[];
|
|
5
|
+
/** Options for [CSS Modules](https://github.com/css-modules/css-modules) */
|
|
6
|
+
export interface ModulesOptions {
|
|
7
|
+
/** Export global classes */
|
|
8
|
+
exportGlobals?: boolean;
|
|
9
|
+
/** Fail on wrong order of composition */
|
|
10
|
+
failOnWrongOrder?: boolean;
|
|
11
|
+
/**
|
|
12
|
+
* Placeholder or function for scoped name generation.
|
|
13
|
+
* Allowed blocks for placeholder:
|
|
14
|
+
* - `[dir]`: The directory name of the asset.
|
|
15
|
+
* - `[name]`: The file name of the asset excluding any extension.
|
|
16
|
+
* - `[local]`: The original value of the selector.
|
|
17
|
+
* - `[hash(:<num>)]`: A hash based on the name and content of the asset (with optional length).
|
|
18
|
+
* @default "[name]_[local]__[hash:8]"
|
|
19
|
+
*/
|
|
20
|
+
generateScopedName?: string | ((name: string, file: string, css: string) => string);
|
|
21
|
+
/**
|
|
22
|
+
* Files to include for [CSS Modules](https://github.com/css-modules/css-modules)
|
|
23
|
+
* for files named `[name].module.[ext]`
|
|
24
|
+
* (e.g. `foo.module.css`, `bar.module.stylus`),
|
|
25
|
+
* or pass your own function or regular expression
|
|
26
|
+
* @default false
|
|
27
|
+
*/
|
|
28
|
+
include?: AutoModules;
|
|
29
|
+
/**
|
|
30
|
+
* Default mode for classes
|
|
31
|
+
* @default "local"
|
|
32
|
+
*/
|
|
33
|
+
mode?: "global" | "local" | "pure";
|
|
34
|
+
}
|
|
35
|
+
export default modules;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { PluginCreator } from "postcss";
|
|
2
|
+
/**
|
|
3
|
+
* No-operation PostCSS plugin used as a fallback when no other plugins are configured.
|
|
4
|
+
*
|
|
5
|
+
* This plugin prevents PostCSS from showing warnings about running without any plugins.
|
|
6
|
+
* It performs no transformations on the CSS - it simply ensures PostCSS has at least
|
|
7
|
+
* one plugin to execute, which is required for proper PostCSS operation.
|
|
8
|
+
*
|
|
9
|
+
* The plugin is automatically added when:
|
|
10
|
+
* - No user plugins are configured
|
|
11
|
+
* - No config file plugins are found
|
|
12
|
+
* - No built-in plugins (import, url, modules) are enabled
|
|
13
|
+
* @example
|
|
14
|
+
* ```typescript
|
|
15
|
+
* // Used internally when plugins array is empty
|
|
16
|
+
* if (plugins.length === 0) {
|
|
17
|
+
* plugins.push(postcssNoop);
|
|
18
|
+
* }
|
|
19
|
+
* ```
|
|
20
|
+
*/
|
|
21
|
+
declare const postcssNoop: PluginCreator<unknown>;
|
|
22
|
+
export default postcssNoop;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import type { PluginCreator } from "postcss";
|
|
2
|
+
import type { UrlResolve } from "./url-resolve.d.ts";
|
|
3
|
+
declare const plugin: PluginCreator<UrlOptions>;
|
|
4
|
+
/** URL handler options */
|
|
5
|
+
export interface UrlOptions {
|
|
6
|
+
/**
|
|
7
|
+
* Aliases for URL paths.
|
|
8
|
+
* Overrides the global `alias` option.
|
|
9
|
+
* - ex.: `{"foo":"bar"}`
|
|
10
|
+
*/
|
|
11
|
+
alias?: Record<string, string>;
|
|
12
|
+
/**
|
|
13
|
+
* Directory path for outputted CSS assets,
|
|
14
|
+
* which is not included into resulting URL
|
|
15
|
+
* @default "."
|
|
16
|
+
*/
|
|
17
|
+
assetDir?: string | ((original: string, resolved: string, file: string) => string);
|
|
18
|
+
/**
|
|
19
|
+
* Enable/disable name generation with hash for outputted CSS assets
|
|
20
|
+
* or provide your own placeholder with the following blocks:
|
|
21
|
+
* - `[extname]`: The file extension of the asset including a leading dot, e.g. `.png`.
|
|
22
|
+
* - `[ext]`: The file extension without a leading dot, e.g. `png`.
|
|
23
|
+
* - `[hash(:<num>)]`: A hash based on the name and content of the asset (with optional length).
|
|
24
|
+
* - `[name]`: The file name of the asset excluding any extension.
|
|
25
|
+
*
|
|
26
|
+
* Forward slashes / can be used to place files in sub-directories.
|
|
27
|
+
* @default "assets/[name]-[hash][extname]" ("assets/[name][extname]" if false)
|
|
28
|
+
*/
|
|
29
|
+
hash?: boolean | string;
|
|
30
|
+
/**
|
|
31
|
+
* Inline files instead of copying
|
|
32
|
+
* @default true for `inject` mode, otherwise false
|
|
33
|
+
*/
|
|
34
|
+
inline?: boolean;
|
|
35
|
+
/**
|
|
36
|
+
* Public Path for URLs in CSS files
|
|
37
|
+
* @default "./"
|
|
38
|
+
*/
|
|
39
|
+
publicPath?: string | ((original: string, resolved: string, file: string) => string);
|
|
40
|
+
/**
|
|
41
|
+
* Provide custom resolver for URLs
|
|
42
|
+
* in place of the default one
|
|
43
|
+
*/
|
|
44
|
+
resolve?: UrlResolve;
|
|
45
|
+
}
|
|
46
|
+
export default plugin;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Converts a file to a data URI for inline embedding in CSS.
|
|
3
|
+
*
|
|
4
|
+
* Creates a data URI that can be used directly in CSS
|
|
5
|
+
* without requiring a separate file request. All files are encoded
|
|
6
|
+
* using base64 for consistent behavior.
|
|
7
|
+
* @param file File path used to determine MIME type
|
|
8
|
+
* @param source File content as Uint8Array to be encoded
|
|
9
|
+
* @returns Data URI string optimized for CSS usage
|
|
10
|
+
* @example
|
|
11
|
+
* ```ts
|
|
12
|
+
* inlineFile("image.png", pngBuffer)
|
|
13
|
+
* // Returns: "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAA..."
|
|
14
|
+
*
|
|
15
|
+
* inlineFile("icon.svg", svgBuffer)
|
|
16
|
+
* // Returns: "data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDov..."
|
|
17
|
+
* ```
|
|
18
|
+
*/
|
|
19
|
+
declare const inline: (file: string, source: Uint8Array) => string;
|
|
20
|
+
export default inline;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/** File resolved by URL resolver */
|
|
2
|
+
export interface UrlFile {
|
|
3
|
+
/** Absolute path to file */
|
|
4
|
+
from: string;
|
|
5
|
+
/** File source */
|
|
6
|
+
source: Uint8Array;
|
|
7
|
+
/** Original query extracted from the input path */
|
|
8
|
+
urlQuery?: string;
|
|
9
|
+
}
|
|
10
|
+
/** URL resolver */
|
|
11
|
+
export type UrlResolve = (inputUrl: string, baseDirectories: string[]) => Promise<UrlFile>;
|
|
12
|
+
export declare const urlResolve: UrlResolve;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { Declaration } from "postcss";
|
|
2
|
+
import type { Node, ParsedValue } from "postcss-value-parser";
|
|
3
|
+
export declare const isDeclWithUrl: (decl: Declaration) => boolean;
|
|
4
|
+
export declare const walkUrls: (parsed: ParsedValue, callback: (url: string, node?: Node) => void) => void;
|
|
@@ -1,17 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
import 'cssnano';
|
|
4
|
-
import 'lightningcss';
|
|
5
|
-
import 'postcss';
|
|
6
|
-
import 'postcss-load-config';
|
|
7
|
-
import '@visulima/packem-share/types';
|
|
8
|
-
import 'sass';
|
|
9
|
-
import 'sass-embedded';
|
|
10
|
-
import 'stylus';
|
|
11
|
-
import '@visulima/packem-share/utils';
|
|
12
|
-
import 'rollup';
|
|
13
|
-
import 'source-map-js';
|
|
14
|
-
|
|
1
|
+
import type { Loader } from "../types.d.ts";
|
|
2
|
+
import type { SassLoaderOptions } from "./types.d.ts";
|
|
15
3
|
declare const loader: Loader<SassLoaderOptions>;
|
|
16
|
-
|
|
17
|
-
export {
|
|
4
|
+
export default loader;
|
|
5
|
+
export type { SassLoaderContext, SassLoaderOptions } from "./types.d.ts";
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Modified copy of https://github.com/webpack-contrib/sass-loader
|
|
3
|
+
*
|
|
4
|
+
* MIT License
|
|
5
|
+
*
|
|
6
|
+
* Copyright JS Foundation and other contributors
|
|
7
|
+
*/
|
|
8
|
+
import type { Environment } from "@visulima/packem-share/types";
|
|
9
|
+
import type { StringOptions as SassStringOptions } from "sass";
|
|
10
|
+
import type { StringOptions as SassEmbeddedStringOptions } from "sass-embedded";
|
|
11
|
+
export type SassLoaderContext = {
|
|
12
|
+
environment: Environment;
|
|
13
|
+
resourcePath: string;
|
|
14
|
+
rootContext: string;
|
|
15
|
+
};
|
|
16
|
+
export type SassLoaderOptions = {
|
|
17
|
+
additionalData: string | ((content: string | Buffer, loaderContext: SassLoaderContext) => Promise<string>) | ((content: string | Buffer, loaderContext: SassLoaderContext) => string);
|
|
18
|
+
implementation?: "sass-embedded" | "sass";
|
|
19
|
+
warnRuleAsWarning?: boolean;
|
|
20
|
+
} & (Omit<SassEmbeddedStringOptions<"sync">, "charset" | "indentedSyntax"> | Omit<SassStringOptions<"sync">, "charset" | "indentedSyntax">);
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type * as sass from "sass";
|
|
2
|
+
import type * as sassEmbedded from "sass-embedded";
|
|
3
|
+
declare const getSassCompiler: (implementation: "sass-embedded" | "sass" | undefined) => Promise<((sassOptions: sass.StringOptions<"sync"> & {
|
|
4
|
+
data: string;
|
|
5
|
+
}) => sass.CompileResult) | ((sassOptions: sassEmbedded.StringOptions<"sync"> & {
|
|
6
|
+
data: string;
|
|
7
|
+
}) => sassEmbedded.CompileResult)>;
|
|
8
|
+
export default getSassCompiler;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { RollupLogger } from "@visulima/packem-share/utils";
|
|
2
|
+
import type { SassLoaderContext, SassLoaderOptions } from "../types.d.ts";
|
|
3
|
+
/**
|
|
4
|
+
* Derives the sass options from the loader context and normalizes its values with sane defaults.
|
|
5
|
+
*/
|
|
6
|
+
declare const getSassOptions: (loaderContext: SassLoaderContext, logger: RollupLogger, options: SassLoaderOptions, content: string, useSourceMap: boolean) => Promise<SassLoaderOptions>;
|
|
7
|
+
export default getSassOptions;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
type SassError = Error & {
|
|
2
|
+
column?: number;
|
|
3
|
+
id: string;
|
|
4
|
+
line?: number;
|
|
5
|
+
};
|
|
6
|
+
declare const errorFactory: (error: Error & {
|
|
7
|
+
formatted?: string;
|
|
8
|
+
span?: {
|
|
9
|
+
start: {
|
|
10
|
+
column: number;
|
|
11
|
+
line: number;
|
|
12
|
+
};
|
|
13
|
+
};
|
|
14
|
+
}, file: string) => SassError;
|
|
15
|
+
export default errorFactory;
|
|
@@ -1,16 +1,25 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
1
|
+
import type { Loader } from "./types.d.ts";
|
|
2
|
+
/**
|
|
3
|
+
* Source map loader for extracting and processing inline source maps from CSS.
|
|
4
|
+
*
|
|
5
|
+
* This loader:
|
|
6
|
+
* - Extracts inline source maps from CSS comments
|
|
7
|
+
* - Strips source map comments from the CSS content
|
|
8
|
+
* - Provides the extracted source map for further processing
|
|
9
|
+
*
|
|
10
|
+
* This loader always processes files regardless of file type since source maps
|
|
11
|
+
* can be present in any CSS content.
|
|
12
|
+
* @example
|
|
13
|
+
* ```css
|
|
14
|
+
* // Input CSS with inline source map
|
|
15
|
+
* .example { color: red; }
|
|
16
|
+
* //# sourceMappingURL=data:application/json;base64,...
|
|
17
|
+
* ```
|
|
18
|
+
* @example
|
|
19
|
+
* ```css
|
|
20
|
+
* // Output CSS with source map stripped
|
|
21
|
+
* .example { color: red; }
|
|
22
|
+
* ```
|
|
23
|
+
*/
|
|
14
24
|
declare const loader: Loader;
|
|
15
|
-
|
|
16
|
-
export { loader as default };
|
|
25
|
+
export default loader;
|
|
@@ -1,17 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
import 'postcss-load-config';
|
|
7
|
-
import '@visulima/packem-share/types';
|
|
8
|
-
import 'sass';
|
|
9
|
-
import 'sass-embedded';
|
|
10
|
-
import 'stylus';
|
|
11
|
-
import '@visulima/packem-share/utils';
|
|
12
|
-
import 'rollup';
|
|
13
|
-
import 'source-map-js';
|
|
14
|
-
|
|
1
|
+
import type { Loader } from "../types.d.ts";
|
|
2
|
+
import type { StylusLoaderOptions } from "./types.d.ts";
|
|
3
|
+
/**
|
|
4
|
+
* Stylus loader for processing Stylus stylesheets to CSS.
|
|
5
|
+
*/
|
|
15
6
|
declare const loader: Loader<StylusLoaderOptions>;
|
|
16
|
-
|
|
17
|
-
export { StylusLoaderOptions,
|
|
7
|
+
export default loader;
|
|
8
|
+
export type { StylusDefinition, StylusLoaderContext, StylusLoaderOptions, StylusPlugin } from "./types.d.ts";
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import type { Environment } from "@visulima/packem-share/types";
|
|
2
|
+
import type { RenderOptions } from "stylus";
|
|
3
|
+
/**
|
|
4
|
+
* Minimal context passed to `additionalData` functions.
|
|
5
|
+
*/
|
|
6
|
+
export type StylusLoaderContext = {
|
|
7
|
+
environment: Environment;
|
|
8
|
+
resourcePath: string;
|
|
9
|
+
rootContext: string;
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* Stylus plugin: either a function that receives the renderer,
|
|
13
|
+
* or a module id (string) that resolves to a plugin factory.
|
|
14
|
+
*/
|
|
15
|
+
export type StylusPlugin = string | ((renderer: unknown) => void);
|
|
16
|
+
/**
|
|
17
|
+
* Definition entry: `[name, value]` or `[name, value, raw]`.
|
|
18
|
+
*/
|
|
19
|
+
export type StylusDefinition = [string, unknown] | [string, unknown, boolean];
|
|
20
|
+
/**
|
|
21
|
+
* Configuration options for the Stylus loader.
|
|
22
|
+
*
|
|
23
|
+
* Extends the standard Stylus RenderOptions with loader-specific functionality.
|
|
24
|
+
* These options are passed to the Stylus compiler during processing.
|
|
25
|
+
* @example
|
|
26
|
+
* ```typescript
|
|
27
|
+
* const stylusOptions: StylusLoaderOptions = {
|
|
28
|
+
* paths: ['./styles', './node_modules'],
|
|
29
|
+
* define: { 'primary-color': '#007acc' },
|
|
30
|
+
* import: ['nib'],
|
|
31
|
+
* use: ['nib'],
|
|
32
|
+
* compress: true,
|
|
33
|
+
* };
|
|
34
|
+
* ```
|
|
35
|
+
* @see {@link https://stylus-lang.com/docs/js.html} Stylus.js API Documentation
|
|
36
|
+
*/
|
|
37
|
+
export type StylusLoaderOptions = {
|
|
38
|
+
/**
|
|
39
|
+
* Prepends or appends Stylus code to the entry file before compilation.
|
|
40
|
+
* Useful for injecting shared variables, mixins, or plugin imports.
|
|
41
|
+
*/
|
|
42
|
+
additionalData?: string | ((content: string, loaderContext: StylusLoaderContext) => Promise<string> | string);
|
|
43
|
+
/**
|
|
44
|
+
* Disable stylus internal cache.
|
|
45
|
+
*/
|
|
46
|
+
disableCache?: boolean;
|
|
47
|
+
/**
|
|
48
|
+
* Hoist `@import`/`@charset` at-rules to the top of the file
|
|
49
|
+
* (maps to stylus `hoist atrules`).
|
|
50
|
+
*/
|
|
51
|
+
hoistAtrules?: boolean;
|
|
52
|
+
/**
|
|
53
|
+
* Custom stylus implementation. Either a module id to import,
|
|
54
|
+
* or a pre-imported Stylus function.
|
|
55
|
+
*/
|
|
56
|
+
implementation?: string | ((code: string, options?: unknown) => unknown);
|
|
57
|
+
/**
|
|
58
|
+
* Files to pre-import before compiling. Equivalent to calling
|
|
59
|
+
* `.import()` on the renderer for each entry.
|
|
60
|
+
*/
|
|
61
|
+
import?: string[];
|
|
62
|
+
/**
|
|
63
|
+
* Additional include paths. Equivalent to calling `.include()`
|
|
64
|
+
* on the renderer for each entry.
|
|
65
|
+
*/
|
|
66
|
+
include?: string[];
|
|
67
|
+
/**
|
|
68
|
+
* Include regular CSS on `@import` (maps to stylus `include css`).
|
|
69
|
+
*/
|
|
70
|
+
includeCSS?: boolean;
|
|
71
|
+
/**
|
|
72
|
+
* Emit comments in the generated CSS indicating the corresponding
|
|
73
|
+
* stylus line (maps to stylus `linenos`).
|
|
74
|
+
*/
|
|
75
|
+
lineNumbers?: boolean;
|
|
76
|
+
/**
|
|
77
|
+
* Pre-define variables/functions on the renderer.
|
|
78
|
+
* Accepts either a plain object keyed by name or a list of
|
|
79
|
+
* `[name, value]` / `[name, value, raw]` tuples.
|
|
80
|
+
*/
|
|
81
|
+
define?: Record<string, unknown> | StylusDefinition[];
|
|
82
|
+
/**
|
|
83
|
+
* Stylus plugins to apply via `.use()`.
|
|
84
|
+
* Strings are resolved and required relative to the current working directory.
|
|
85
|
+
*/
|
|
86
|
+
use?: StylusPlugin[];
|
|
87
|
+
} & RenderOptions;
|
|
@@ -1,16 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
import 'postcss-load-config';
|
|
6
|
-
import '@visulima/packem-share/types';
|
|
7
|
-
import 'sass';
|
|
8
|
-
import 'sass-embedded';
|
|
9
|
-
import 'stylus';
|
|
10
|
-
import '@visulima/packem-share/utils';
|
|
11
|
-
import 'rollup';
|
|
12
|
-
import 'source-map-js';
|
|
13
|
-
|
|
1
|
+
import type { Loader } from "./types.d.ts";
|
|
2
|
+
/**
|
|
3
|
+
* Tailwind Oxide loader for processing Tailwind CSS files
|
|
4
|
+
*/
|
|
14
5
|
declare const tailwindcssLoader: Loader;
|
|
15
|
-
|
|
16
|
-
export { tailwindcssLoader as default };
|
|
6
|
+
export default tailwindcssLoader;
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import type { Environment } from "@visulima/packem-share/types";
|
|
2
|
+
import type { RollupLogger } from "@visulima/packem-share/utils";
|
|
3
|
+
import type { CustomPluginOptions, PluginContext } from "rollup";
|
|
4
|
+
import type { RawSourceMap } from "source-map-js";
|
|
5
|
+
import type { InternalStyleOptions } from "../types.d.ts";
|
|
6
|
+
export interface Extracted {
|
|
7
|
+
/** CSS */
|
|
8
|
+
css: string;
|
|
9
|
+
/** Source file path */
|
|
10
|
+
id: string;
|
|
11
|
+
/** Sourcemap */
|
|
12
|
+
map?: string;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* @param T type of loader's options
|
|
16
|
+
*/
|
|
17
|
+
export interface Loader<T = Record<string, unknown>> {
|
|
18
|
+
/** Skip testing, always process the file */
|
|
19
|
+
alwaysProcess?: boolean;
|
|
20
|
+
/** Name */
|
|
21
|
+
name: string;
|
|
22
|
+
/** Function for processing */
|
|
23
|
+
process: (this: LoaderContext<T>, payload: Payload) => Payload | Promise<Payload>;
|
|
24
|
+
/**
|
|
25
|
+
* Test to control if file should be processed.
|
|
26
|
+
* Also used for plugin's supported files test.
|
|
27
|
+
*/
|
|
28
|
+
test?: RegExp | ((file: string) => boolean);
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* @param T type of loader's options
|
|
32
|
+
*/
|
|
33
|
+
export interface LoaderContext<T = Record<string, unknown>> {
|
|
34
|
+
readonly alias?: Record<string, string>;
|
|
35
|
+
/** Assets to emit */
|
|
36
|
+
readonly assets: Map<string, Uint8Array>;
|
|
37
|
+
/** @see {@link InternalStyleOptions.autoModules} */
|
|
38
|
+
readonly autoModules: InternalStyleOptions["autoModules"];
|
|
39
|
+
/** Browser targets */
|
|
40
|
+
readonly browserTargets: string[];
|
|
41
|
+
readonly cwd?: string;
|
|
42
|
+
readonly debug?: boolean;
|
|
43
|
+
/** Files to watch */
|
|
44
|
+
readonly deps: Set<string>;
|
|
45
|
+
/** @see {@link InternalStyleOptions.dts} */
|
|
46
|
+
readonly dts: InternalStyleOptions["dts"];
|
|
47
|
+
/** @see {@link InternalStyleOptions.emit} */
|
|
48
|
+
readonly emit: InternalStyleOptions["emit"];
|
|
49
|
+
readonly environment: Environment;
|
|
50
|
+
/** @see {@link InternalStyleOptions.extensions} */
|
|
51
|
+
readonly extensions: InternalStyleOptions["extensions"];
|
|
52
|
+
/** @see {@link InternalStyleOptions.extract} */
|
|
53
|
+
readonly extract: InternalStyleOptions["extract"];
|
|
54
|
+
/** Resource path */
|
|
55
|
+
readonly id: string;
|
|
56
|
+
/** @see {@link InternalStyleOptions.inject} */
|
|
57
|
+
readonly inject: InternalStyleOptions["inject"];
|
|
58
|
+
/** @see {@link InternalStyleOptions.inline} */
|
|
59
|
+
readonly inline: InternalStyleOptions["inline"];
|
|
60
|
+
/** Rollup-compatible logger for plugin messages */
|
|
61
|
+
readonly logger: RollupLogger;
|
|
62
|
+
/** @see {@link InternalStyleOptions.namedExports} */
|
|
63
|
+
readonly namedExports: InternalStyleOptions["namedExports"];
|
|
64
|
+
/**
|
|
65
|
+
* Type-safe configuration options passed to the loader instance
|
|
66
|
+
* @default {}
|
|
67
|
+
*/
|
|
68
|
+
readonly options: T;
|
|
69
|
+
/** [Plugin's context](https://rollupjs.org/guide/en#plugin-context) */
|
|
70
|
+
readonly plugin: PluginContext;
|
|
71
|
+
readonly sourceDir?: string;
|
|
72
|
+
/** @see {@link InternalStyleOptions.sourceMap} */
|
|
73
|
+
readonly sourceMap: false | (SourceMapOptions & {
|
|
74
|
+
inline: boolean;
|
|
75
|
+
});
|
|
76
|
+
readonly useSourcemap: boolean;
|
|
77
|
+
}
|
|
78
|
+
export interface Payload {
|
|
79
|
+
/** File content */
|
|
80
|
+
code: string;
|
|
81
|
+
dts?: string;
|
|
82
|
+
/** Extracted data */
|
|
83
|
+
extracted?: Extracted;
|
|
84
|
+
/** Sourcemap */
|
|
85
|
+
map?: string;
|
|
86
|
+
/** Additional metadata exposed to other Rollup plugins */
|
|
87
|
+
meta?: CustomPluginOptions;
|
|
88
|
+
}
|
|
89
|
+
export type PostCSSMeta = {
|
|
90
|
+
icssDependencies: string[];
|
|
91
|
+
moduleContents: string;
|
|
92
|
+
types: string;
|
|
93
|
+
};
|
|
94
|
+
export interface SourceMapOptions {
|
|
95
|
+
/**
|
|
96
|
+
* Include sources content
|
|
97
|
+
* @default true
|
|
98
|
+
*/
|
|
99
|
+
content?: boolean;
|
|
100
|
+
/** Function for transforming resulting sourcemap */
|
|
101
|
+
transform?: (map: RawSourceMap, name?: string) => void;
|
|
102
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type { AutoModules } from "../../types.d.ts";
|
|
2
|
+
/**
|
|
3
|
+
* Determines if CSS modules should be enabled for a given file.
|
|
4
|
+
*
|
|
5
|
+
* This function checks various conditions to decide whether CSS modules
|
|
6
|
+
* processing should be applied to a file:
|
|
7
|
+
*
|
|
8
|
+
* 1. If AutoModules is undefined, defaults to true (enable modules)
|
|
9
|
+
* 2. If AutoModules is a function, calls it with the file ID
|
|
10
|
+
* 3. If AutoModules is a RegExp, tests it against the file ID
|
|
11
|
+
* 4. If AutoModules is true, uses the default module file pattern
|
|
12
|
+
* 5. If AutoModules is false, modules are disabled
|
|
13
|
+
*
|
|
14
|
+
* The default pattern matches files with `.module.` in their name,
|
|
15
|
+
* following the convention used by Vite and other build tools.
|
|
16
|
+
* @param am AutoModules configuration (function, RegExp, boolean, or undefined)
|
|
17
|
+
* @param id File identifier/path to test
|
|
18
|
+
* @returns True if CSS modules should be enabled for this file
|
|
19
|
+
* @example
|
|
20
|
+
* ```typescript
|
|
21
|
+
* // Function-based detection
|
|
22
|
+
* ensureAutoModules((id) => id.includes('.module.'), 'styles.module.css') // true
|
|
23
|
+
*
|
|
24
|
+
* // RegExp-based detection
|
|
25
|
+
* ensureAutoModules(/\.module\./, 'styles.module.css') // true
|
|
26
|
+
*
|
|
27
|
+
* // Boolean enable with default pattern
|
|
28
|
+
* ensureAutoModules(true, 'styles.module.css') // true
|
|
29
|
+
* ensureAutoModules(true, 'styles.css') // false
|
|
30
|
+
*
|
|
31
|
+
* // Boolean disable
|
|
32
|
+
* ensureAutoModules(false, 'styles.module.css') // false
|
|
33
|
+
*
|
|
34
|
+
* // Undefined defaults to true with pattern check
|
|
35
|
+
* ensureAutoModules(undefined, 'styles.module.css') // true
|
|
36
|
+
* ```
|
|
37
|
+
*/
|
|
38
|
+
declare const ensureAutoModules: (am: AutoModules | undefined, id: string) => boolean;
|
|
39
|
+
export default ensureAutoModules;
|