@salty-css/vite 0.1.0-alpha.9 → 0.1.0-refactor-add-additional-paths-to-config-cache.0
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/index.cjs +1 -1
- package/index.d.ts +18 -1
- package/index.js +28 -17
- package/package.json +2 -2
package/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var h=Object.create;var c=Object.defineProperty;var g=Object.getOwnPropertyDescriptor;var p=Object.getOwnPropertyNames;var C=Object.getPrototypeOf,w=Object.prototype.hasOwnProperty;var v=(e,r,o,a)=>{if(r&&typeof r=="object"||typeof r=="function")for(let s of p(r))!w.call(e,s)&&s!==o&&c(e,s,{get:()=>r[s],enumerable:!(a=g(r,s))||a.enumerable});return e};var F=(e,r,o)=>(o=e!=null?h(C(e)):{},v(r||!e||!e.__esModule?c(o,"default",{value:e,enumerable:!0}):o,e));Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const u=require("@salty-css/core/compiler/helpers"),S=require("@salty-css/core/compiler/salty-compiler"),d=require("@salty-css/core/compiler/copy-config-cache"),y=require("@salty-css/core/server"),m=require("path"),R=async e=>{if(e==="react"||e===void 0)return(await import("@salty-css/react/transform-salty-file")).transformSaltyFile;throw new Error(`@salty-css/vite: framework "${e}" is not supported. Supported: react.`)},f=(e,r={})=>{const o=new S.SaltyCompiler(e,{mode:r.mode});let a;const s=()=>(a||(a=o.getFramework().then(R)),a);let n;return{name:"stylegen",configResolved:t=>{n=t},buildStart:async()=>await o.generateCss(),load:async t=>{if(u.isSaltyFile(t))return await(await s())(o,t)},handleHotUpdate:async({file:t,server:i})=>{await y.checkShouldRestart(t)&&i.restart()},watchChange:{handler:async(t,i)=>{u.isSaltyFile(t)&&i.event!=="delete"&&(await y.checkShouldRestart(t)||await o.generateFile(t))}},closeBundle:async()=>{if(!n||n.command!=="build"||!o.isProduction)return;const t=n.build.outDir,i=m.isAbsolute(t)?t:m.resolve(n.root,t),l=d.resolveCopyConfigCacheDestinations(r.copyConfigCache,i,n.root);await d.copyConfigCacheTo(o,l)}}};exports.default=f;exports.saltyPlugin=f;
|
package/index.d.ts
CHANGED
|
@@ -1,3 +1,20 @@
|
|
|
1
|
+
import { SaltyCompilerMode } from '@salty-css/core/compiler/salty-compiler';
|
|
2
|
+
import { CopyConfigCacheOption } from '@salty-css/core/compiler/copy-config-cache';
|
|
1
3
|
import { PluginOption } from 'vite';
|
|
2
|
-
export
|
|
4
|
+
export interface SaltyVitePluginOptions {
|
|
5
|
+
/**
|
|
6
|
+
* Explicit build mode. Defaults to NODE_ENV-based detection.
|
|
7
|
+
*/
|
|
8
|
+
mode?: SaltyCompilerMode;
|
|
9
|
+
/**
|
|
10
|
+
* Where to copy the Salty `config-cache.json` after a production build.
|
|
11
|
+
*
|
|
12
|
+
* - `true` (default) → copy to the bundler's `build.outDir`.
|
|
13
|
+
* - `false` → no copy.
|
|
14
|
+
* - `string | string[]` → copy to the default destination PLUS each listed path.
|
|
15
|
+
* Directories receive `saltygen/cache/config-cache.json`; `.json` paths are used as-is.
|
|
16
|
+
*/
|
|
17
|
+
copyConfigCache?: CopyConfigCacheOption;
|
|
18
|
+
}
|
|
19
|
+
export declare const saltyPlugin: (dir: string, options?: SaltyVitePluginOptions) => PluginOption;
|
|
3
20
|
export default saltyPlugin;
|
package/index.js
CHANGED
|
@@ -1,32 +1,43 @@
|
|
|
1
|
-
import { isSaltyFile as
|
|
2
|
-
import { SaltyCompiler as
|
|
3
|
-
import {
|
|
4
|
-
|
|
1
|
+
import { isSaltyFile as l } from "@salty-css/core/compiler/helpers";
|
|
2
|
+
import { SaltyCompiler as m } from "@salty-css/core/compiler/salty-compiler";
|
|
3
|
+
import { resolveCopyConfigCacheDestinations as u, copyConfigCacheTo as f } from "@salty-css/core/compiler/copy-config-cache";
|
|
4
|
+
import { checkShouldRestart as c } from "@salty-css/core/server";
|
|
5
|
+
import { isAbsolute as y, resolve as p } from "path";
|
|
6
|
+
const w = async (a) => {
|
|
5
7
|
if (a === "react" || a === void 0)
|
|
6
8
|
return (await import("@salty-css/react/transform-salty-file")).transformSaltyFile;
|
|
7
9
|
throw new Error(`@salty-css/vite: framework "${a}" is not supported. Supported: react.`);
|
|
8
|
-
},
|
|
9
|
-
const
|
|
10
|
-
let
|
|
11
|
-
const
|
|
10
|
+
}, S = (a, n = {}) => {
|
|
11
|
+
const o = new m(a, { mode: n.mode });
|
|
12
|
+
let i;
|
|
13
|
+
const d = () => (i || (i = o.getFramework().then(w)), i);
|
|
14
|
+
let e;
|
|
12
15
|
return {
|
|
13
16
|
name: "stylegen",
|
|
14
|
-
|
|
17
|
+
configResolved: (t) => {
|
|
18
|
+
e = t;
|
|
19
|
+
},
|
|
20
|
+
buildStart: async () => await o.generateCss(),
|
|
15
21
|
load: async (t) => {
|
|
16
|
-
if (
|
|
17
|
-
return await (await
|
|
22
|
+
if (l(t))
|
|
23
|
+
return await (await d())(o, t);
|
|
18
24
|
},
|
|
19
|
-
handleHotUpdate: async ({ file: t, server:
|
|
20
|
-
await
|
|
25
|
+
handleHotUpdate: async ({ file: t, server: r }) => {
|
|
26
|
+
await c(t) && r.restart();
|
|
21
27
|
},
|
|
22
28
|
watchChange: {
|
|
23
|
-
handler: async (t,
|
|
24
|
-
|
|
29
|
+
handler: async (t, r) => {
|
|
30
|
+
l(t) && r.event !== "delete" && (await c(t) || await o.generateFile(t));
|
|
25
31
|
}
|
|
32
|
+
},
|
|
33
|
+
closeBundle: async () => {
|
|
34
|
+
if (!e || e.command !== "build" || !o.isProduction) return;
|
|
35
|
+
const t = e.build.outDir, r = y(t) ? t : p(e.root, t), s = u(n.copyConfigCache, r, e.root);
|
|
36
|
+
await f(o, s);
|
|
26
37
|
}
|
|
27
38
|
};
|
|
28
39
|
};
|
|
29
40
|
export {
|
|
30
|
-
|
|
31
|
-
|
|
41
|
+
S as default,
|
|
42
|
+
S as saltyPlugin
|
|
32
43
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@salty-css/vite",
|
|
3
|
-
"version": "0.1.0-
|
|
3
|
+
"version": "0.1.0-refactor-add-additional-paths-to-config-cache.0",
|
|
4
4
|
"main": "./dist/index.js",
|
|
5
5
|
"module": "./dist/index.mjs",
|
|
6
6
|
"typings": "./dist/index.d.ts",
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
}
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"@salty-css/core": "^0.1.0-
|
|
37
|
+
"@salty-css/core": "^0.1.0-refactor-add-additional-paths-to-config-cache.0",
|
|
38
38
|
"vite": "^6.4.1"
|
|
39
39
|
},
|
|
40
40
|
"peerDependencies": {
|