@fastkit/plugboy-sass-plugin 3.0.0-next.0 → 3.0.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.
|
@@ -2,10 +2,8 @@ import { definePlugin } from "@fastkit/plugboy";
|
|
|
2
2
|
import sass from "rollup-plugin-sass";
|
|
3
3
|
import { parse, resolve } from "path";
|
|
4
4
|
import { existsSync } from "fs";
|
|
5
|
-
|
|
6
5
|
//#region src/types.ts
|
|
7
6
|
const PLUGIN_NAME = "plugboy-sass";
|
|
8
|
-
|
|
9
7
|
//#endregion
|
|
10
8
|
//#region src/utils.ts
|
|
11
9
|
function modulesPaths(absWorkingDir) {
|
|
@@ -19,7 +17,6 @@ function modulesPaths(absWorkingDir) {
|
|
|
19
17
|
}
|
|
20
18
|
return [...found];
|
|
21
19
|
}
|
|
22
|
-
|
|
23
20
|
//#endregion
|
|
24
21
|
//#region src/plugin.ts
|
|
25
22
|
function createSassPlugin(options = {}) {
|
|
@@ -68,7 +65,7 @@ function createSassPlugin(options = {}) {
|
|
|
68
65
|
}
|
|
69
66
|
});
|
|
70
67
|
}
|
|
71
|
-
|
|
72
68
|
//#endregion
|
|
73
69
|
export { createSassPlugin };
|
|
70
|
+
|
|
74
71
|
//# sourceMappingURL=plugboy-sass-plugin.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugboy-sass-plugin.mjs","names":[],"sources":["../src/types.ts","../src/utils.ts","../src/plugin.ts"],"sourcesContent":["import { Plugin } from '@fastkit/plugboy';\nimport sass from 'rollup-plugin-sass';\nimport { type Options as SassOptions } from 'sass';\n\ntype RollupPluginSassOptions = NonNullable<Parameters<typeof sass>[0]>;\n\nexport interface PluginOptions
|
|
1
|
+
{"version":3,"file":"plugboy-sass-plugin.mjs","names":[],"sources":["../src/types.ts","../src/utils.ts","../src/plugin.ts"],"sourcesContent":["import { Plugin } from '@fastkit/plugboy';\nimport sass from 'rollup-plugin-sass';\nimport { type Options as SassOptions } from 'sass';\n\ntype RollupPluginSassOptions = NonNullable<Parameters<typeof sass>[0]>;\n\nexport interface PluginOptions extends Pick<\n RollupPluginSassOptions,\n 'include' | 'exclude'\n> {\n sass?: SassOptions<'async'>;\n}\n\nexport const PLUGIN_NAME = 'plugboy-sass';\n\nexport interface SassPlugin extends Plugin {\n name: typeof PLUGIN_NAME;\n _options: PluginOptions;\n}\n","import { parse, resolve } from 'path';\nimport { existsSync } from 'fs';\n\nexport function modulesPaths(absWorkingDir?: string): string[] {\n let path = absWorkingDir || process.cwd();\n const { root } = parse(path);\n const found: string[] = [];\n\n while (path !== root) {\n const filename = resolve(path, 'node_modules');\n if (existsSync(filename)) {\n found.push(filename);\n }\n path = resolve(path, '..');\n }\n return [...found];\n}\n","import { definePlugin, type TryGetWorkspace } from '@fastkit/plugboy';\nimport sass from 'rollup-plugin-sass';\nimport { PLUGIN_NAME, PluginOptions, SassPlugin } from './types';\nimport { modulesPaths } from './utils';\n\nexport function createSassPlugin(options: PluginOptions = {}) {\n let _styles = '';\n\n const { sass: sassOptions, ...restOptions } = options;\n\n const {\n name: _name,\n generateBundle,\n ...sassPluginSettings\n } = sass({\n api: 'modern',\n ...restOptions,\n options: {\n ...sassOptions,\n loadPaths: Array.from(\n new Set([...(sassOptions?.loadPaths || modulesPaths())]),\n ),\n },\n output(styles) {\n _styles = styles;\n },\n });\n\n let _getWorkspace: TryGetWorkspace;\n\n return definePlugin<SassPlugin>({\n name: PLUGIN_NAME,\n _options: options,\n ...(sassPluginSettings as any),\n hooks: {\n setupWorkspace(_, getWorkspace) {\n _getWorkspace = getWorkspace;\n },\n },\n async generateBundle(outputOptions, bundle, isWrite) {\n if (typeof generateBundle === 'function') {\n await generateBundle.call(\n this as any,\n outputOptions as any,\n bundle as any,\n isWrite,\n );\n }\n\n if (!_styles) return;\n\n let cssFile = outputOptions.file;\n\n if (!cssFile) {\n const workspace = _getWorkspace();\n\n const cssExport = workspace?.exports.find((e) => e.id.endsWith('.css'));\n if (cssExport) {\n const tmp = cssExport.id.split('/');\n cssFile = tmp[tmp.length - 1];\n } else {\n const fileNames = Object.keys(bundle);\n const jsFile = fileNames.find((f) => /\\.m?js$/.test(f));\n\n if (!jsFile) {\n return;\n }\n cssFile = jsFile.replace(/\\.m?js$/, '.css');\n }\n }\n this.emitFile({\n type: 'asset',\n name: cssFile,\n fileName: cssFile,\n source: _styles,\n });\n },\n });\n}\n"],"mappings":";;;;;AAaA,MAAa,cAAc;;;ACV3B,SAAgB,aAAa,eAAkC;CAC7D,IAAI,OAAO,iBAAiB,QAAQ,IAAI;CACxC,MAAM,EAAE,SAAS,MAAM,IAAI;CAC3B,MAAM,QAAkB,CAAC;CAEzB,OAAO,SAAS,MAAM;EACpB,MAAM,WAAW,QAAQ,MAAM,cAAc;EAC7C,IAAI,WAAW,QAAQ,GACrB,MAAM,KAAK,QAAQ;EAErB,OAAO,QAAQ,MAAM,IAAI;CAC3B;CACA,OAAO,CAAC,GAAG,KAAK;AAClB;;;ACXA,SAAgB,iBAAiB,UAAyB,CAAC,GAAG;CAC5D,IAAI,UAAU;CAEd,MAAM,EAAE,MAAM,aAAa,GAAG,gBAAgB;CAE9C,MAAM,EACJ,MAAM,OACN,gBACA,GAAG,uBACD,KAAK;EACP,KAAK;EACL,GAAG;EACH,SAAS;GACP,GAAG;GACH,WAAW,MAAM,KACf,IAAI,IAAI,CAAC,GAAI,aAAa,aAAa,aAAa,CAAE,CAAC,CACzD;EACF;EACA,OAAO,QAAQ;GACb,UAAU;EACZ;CACF,CAAC;CAED,IAAI;CAEJ,OAAO,aAAyB;EAC9B,MAAM;EACN,UAAU;EACV,GAAI;EACJ,OAAO,EACL,eAAe,GAAG,cAAc;GAC9B,gBAAgB;EAClB,EACF;EACA,MAAM,eAAe,eAAe,QAAQ,SAAS;GACnD,IAAI,OAAO,mBAAmB,YAC5B,MAAM,eAAe,KACnB,MACA,eACA,QACA,OACF;GAGF,IAAI,CAAC,SAAS;GAEd,IAAI,UAAU,cAAc;GAE5B,IAAI,CAAC,SAAS;IAGZ,MAAM,YAFY,cAEQ,CAAC,EAAE,QAAQ,MAAM,MAAM,EAAE,GAAG,SAAS,MAAM,CAAC;IACtE,IAAI,WAAW;KACb,MAAM,MAAM,UAAU,GAAG,MAAM,GAAG;KAClC,UAAU,IAAI,IAAI,SAAS;IAC7B,OAAO;KAEL,MAAM,SADY,OAAO,KAAK,MACP,CAAC,CAAC,MAAM,MAAM,UAAU,KAAK,CAAC,CAAC;KAEtD,IAAI,CAAC,QACH;KAEF,UAAU,OAAO,QAAQ,WAAW,MAAM;IAC5C;GACF;GACA,KAAK,SAAS;IACZ,MAAM;IACN,MAAM;IACN,UAAU;IACV,QAAQ;GACV,CAAC;EACH;CACF,CAAC;AACH"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fastkit/plugboy-sass-plugin",
|
|
3
|
-
"version": "3.0.0
|
|
3
|
+
"version": "3.0.0",
|
|
4
4
|
"description": "plugboy-sass-plugin",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"plugboy",
|
|
@@ -37,13 +37,13 @@
|
|
|
37
37
|
],
|
|
38
38
|
"dependencies": {
|
|
39
39
|
"rollup-plugin-sass": "^1.15.3",
|
|
40
|
-
"sass": "^1.
|
|
40
|
+
"sass": "^1.101.0"
|
|
41
41
|
},
|
|
42
42
|
"devDependencies": {
|
|
43
|
-
"@fastkit/plugboy": "^1.0.0
|
|
43
|
+
"@fastkit/plugboy": "^1.0.0"
|
|
44
44
|
},
|
|
45
45
|
"peerDependencies": {
|
|
46
|
-
"@fastkit/plugboy": "^1.0.0
|
|
46
|
+
"@fastkit/plugboy": "^1.0.0"
|
|
47
47
|
},
|
|
48
48
|
"scripts": {
|
|
49
49
|
"build": "plugboy build",
|