From e78dae09a6ed52cb96515273d4b9956f98148150 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=89=A7=E6=AF=85?= Date: Fri, 21 Aug 2020 11:04:06 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=F0=9F=8E=B8=20globalStyle=20=E6=94=AF?= =?UTF-8?q?=E6=8C=81=E5=AE=9A=E5=88=B6=E6=A0=B7=E5=BC=8F=E6=96=87=E4=BB=B6?= =?UTF-8?q?=E7=9A=84=E5=90=8E=E7=BC=80=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../framework/rax/plugins/globalStyle.ts | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/packages/code-generator/src/plugins/project/framework/rax/plugins/globalStyle.ts b/packages/code-generator/src/plugins/project/framework/rax/plugins/globalStyle.ts index 78e409fd2..ce3689f2b 100644 --- a/packages/code-generator/src/plugins/project/framework/rax/plugins/globalStyle.ts +++ b/packages/code-generator/src/plugins/project/framework/rax/plugins/globalStyle.ts @@ -9,7 +9,18 @@ import { IProjectInfo, } from '../../../../../types'; -const pluginFactory: BuilderComponentPluginFactory = () => { +export type GlobalStylePluginConfig = { + fileType: string; +}; + +const pluginFactory: BuilderComponentPluginFactory = ( + config?: Partial, +) => { + const cfg: GlobalStylePluginConfig = { + fileType: FileType.SCSS, + ...config, + }; + const plugin: BuilderComponentPlugin = async (pre: ICodeStruct) => { const next: ICodeStruct = { ...pre, @@ -19,7 +30,7 @@ const pluginFactory: BuilderComponentPluginFactory = () => { next.chunks.push({ type: ChunkType.STRING, - fileType: FileType.SCSS, // TODO: 样式文件的类型定制化? + fileType: cfg.fileType, name: COMMON_CHUNK_NAME.StyleDepsImport, content: ``, linkAfter: [], @@ -27,7 +38,7 @@ const pluginFactory: BuilderComponentPluginFactory = () => { next.chunks.push({ type: ChunkType.STRING, - fileType: FileType.SCSS, + fileType: cfg.fileType, name: COMMON_CHUNK_NAME.StyleCssContent, content: ` body { @@ -39,7 +50,7 @@ body { next.chunks.push({ type: ChunkType.STRING, - fileType: FileType.SCSS, + fileType: cfg.fileType, name: COMMON_CHUNK_NAME.StyleCssContent, content: ir.css || '', linkAfter: [COMMON_CHUNK_NAME.StyleDepsImport],