Skip to content

Commit

Permalink
fix: reslove pakcages export issue
Browse files Browse the repository at this point in the history
  • Loading branch information
LonelySnowman committed Nov 14, 2024
1 parent 5cd5c0b commit e5da1ae
Show file tree
Hide file tree
Showing 8 changed files with 58 additions and 12 deletions.
6 changes: 6 additions & 0 deletions packages/components/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@
"main": "lib/cjs/index.js",
"module": "lib/es/index.js",
"typings": "lib/es/index.d.ts",
"exports": {
".": {
"import": "./lib/es/index.js",
"require": "./lib/cjs/index.js"
}
},
"files": [
"dist/*",
"lib/*"
Expand Down
16 changes: 13 additions & 3 deletions packages/locale/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,19 @@
"version:major": "npm version major --no-git-tag-version"
},
"description": "SnowDesign 组件库国际化语言包",
"main": "lib/cjs/index.js",
"module": "lib/es/index.js",
"types": "lib/cjs/index.d.ts",
"main": "./lib/cjs/index.js",
"module": "./lib/es/index.js",
"types": "./lib/cjs/index.d.ts",
"exports": {
"zh_CN": {
"import": "./lib/es/zh_CN.js",
"require": "./lib/cjs/zh_CN.js"
},
"en_US": {
"import": "./lib/es/en_US.js",
"require": "./lib/cjs/en_US.js"
}
},
"keywords": [
"snow-design"
],
Expand Down
13 changes: 10 additions & 3 deletions packages/vite-plugin/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,15 @@
"name": "@snow-design/vite-plugin",
"version": "0.0.30",
"description": "SnowDesign 组件库主题包 Vite 插件",
"main": "dist/index.cjs",
"types": "dist/index.d.ts",
"module": "dist/index.mjs",
"main": "lib/index.js",
"types": "lib/index.d.ts",
"module": "lib/index.mjs",
"exports": {
".": {
"import": "./lib/index.mjs",
"require": "./lib/index.js"
}
},
"scripts": {
"build": "tsup-node",
"clean": "rimraf lib node_modules",
Expand All @@ -24,6 +30,7 @@
"@types/node": "^20.10.4"
},
"dependencies": {
"@snow-design/theme-default": "workspace:*",
"enhanced-resolve": "^5.15.0",
"sass": "^1.80.6",
"vite": "^5.0.7"
Expand Down
6 changes: 4 additions & 2 deletions packages/vite-plugin/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ export default function SnowDesignVitePlugin(options: SnowVitePluginOptions): Pl

function loader(source: Buffer, options: SnowVitePluginOptions, config: ResolvedConfig) {
let fileStr = source.toString(); // 文件原本的内容
fileStr = fileStr.replace(/(@import '.\/variables.scss';?|@import ".\/variables.scss";?)/g, '');
fileStr = fileStr.replace(/(@import ['"]\.\/variables.*?['"];?)/g, '');

const defaultTheme = '@snow-design/theme-default';
const customTheme = options.theme;
Expand All @@ -77,6 +77,8 @@ function loader(source: Buffer, options: SnowVitePluginOptions, config: Resolved
SCSSVarStr += `@import "~${defaultTheme}/scss/index.scss";\n`;
console.error(`[SnowDesign ERROR]: ${customTheme}/scss/index.scss not exist!`);
}
} else {
SCSSVarStr += `@import "~${defaultTheme}/scss/index.scss";\n`;
}

// 本地组件级变量配置
Expand All @@ -93,7 +95,7 @@ function loader(source: Buffer, options: SnowVitePluginOptions, config: Resolved

// 自定义 CSS 类名前缀
if (options.prefixCls) {
SCSSVarStr += `$prefix: '${options.prefixCls}';`;
SCSSVarStr += `$prefix: '${options.prefixCls}';\n`;
}

return `${SCSSVarStr}${fileStr}`;
Expand Down
6 changes: 6 additions & 0 deletions packages/vue3/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@
"main": "lib/cjs/index.js",
"module": "lib/es/index.js",
"typings": "lib/es/index.d.ts",
"exports": {
".": {
"import": "./lib/es/index.js",
"require": "./lib/cjs/index.js"
}
},
"files": [
"dist/*",
"lib/*",
Expand Down
13 changes: 10 additions & 3 deletions packages/webpack-plugin/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,15 @@
"name": "@snow-design/webpack-plugin",
"version": "0.0.30",
"description": "SnowDesign 组件库主题包 Webpack 插件",
"main": "lib/cjs/index.js",
"module": "lib/es/index.js",
"types": "lib/cjs/index.js",
"main": "./lib/cjs/index.js",
"module": "./lib/es/index.js",
"types": "./lib/cjs/index.js",
"exports": {
".": {
"import": "./lib/es/index.js",
"require": "./lib/cjs/index.js"
}
},
"scripts": {
"build:lib": "tsup-node",
"build": "pnpm run build:lib",
Expand All @@ -23,6 +29,7 @@
"author": "LonelySnowman",
"license": "ISC",
"dependencies": {
"@snow-design/theme-default": "workspace:*",
"@types/node": "^20.10.4",
"enhanced-resolve": "^5.15.0",
"loader-utils": "^2.0.4",
Expand Down
4 changes: 3 additions & 1 deletion packages/webpack-plugin/src/snow-theme-loader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export default function snowThemeLoader(source: string) {
const options = loaderUtils.getOptions(this);

let fileStr = source; // 文件原本的内容
fileStr = fileStr.replace(/(@import '.\/variables.scss';?|@import ".\/variables.scss";?)/g, '');
fileStr = fileStr.replace(/(@import ['"]\.\/variables.*?['"];?)/g, '');

const defaultTheme = '@snow-design/theme-default';
const customTheme = options.theme;
Expand All @@ -22,6 +22,8 @@ export default function snowThemeLoader(source: string) {
SCSSVarStr += `@import "~${defaultTheme}/scss/index.scss";\n`;
console.error(`[SnowDesign ERROR]: ${customTheme}/scss/index.scss not exist!`);
}
} else {
SCSSVarStr += `@import "~${defaultTheme}/scss/index.scss";\n`;
}

// 本地组件级变量配置
Expand Down
6 changes: 6 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit e5da1ae

Please sign in to comment.