feat: 修改stystem-ui的页面打包
This commit is contained in:
64
apps/ui/config/rollup.components.config.js
Normal file
64
apps/ui/config/rollup.components.config.js
Normal file
@@ -0,0 +1,64 @@
|
||||
import resolve from '@rollup/plugin-node-resolve';
|
||||
import typescript from '@rollup/plugin-typescript';
|
||||
import commonjs from '@rollup/plugin-commonjs';
|
||||
import postcss from 'rollup-plugin-postcss';
|
||||
import autoprefixer from 'autoprefixer';
|
||||
import cssnano from 'cssnano';
|
||||
import terser from '@rollup/plugin-terser';
|
||||
|
||||
import postcssImport from 'postcss-import';
|
||||
import dts from 'rollup-plugin-dts';
|
||||
|
||||
import * as glob from 'glob';
|
||||
import path from 'path';
|
||||
const isApps = process.env.TYPE === 'apps';
|
||||
const components = glob.sync('./src/components/**/index.ts');
|
||||
const entrys = components.map((entry) => {
|
||||
return entry;
|
||||
});
|
||||
console.log('entry', entrys);
|
||||
const output = path.resolve('./dist');
|
||||
console.log('output', output);
|
||||
/**
|
||||
* @type {import('rollup').RollupOptions[]}
|
||||
*/
|
||||
const configs = entrys
|
||||
.map((entry) => {
|
||||
const directory = path.dirname(entry);
|
||||
const lastDirectory = directory.split('/').pop();
|
||||
const input = path.resolve(entry);
|
||||
const buildConfig = {
|
||||
input: input, // 修改输入文件为 TypeScript 文件
|
||||
output: {
|
||||
file: path.join(output, `./${lastDirectory}.js`),
|
||||
format: 'es', // 输出格式为 ES Module
|
||||
},
|
||||
plugins: [
|
||||
resolve({
|
||||
browser: true, // 处理浏览器版本的依赖
|
||||
}),
|
||||
commonjs(),
|
||||
typescript({
|
||||
tsconfig: './tsconfig.json',
|
||||
compilerOptions: {
|
||||
declaration: false, // 生成声明文件
|
||||
declarationDir: './dist', // 声明文件输出目录
|
||||
// outDir: './types', //
|
||||
},
|
||||
}), // 添加 TypeScript 插件
|
||||
// terser(), // 压缩输出的 ES Module 文件
|
||||
],
|
||||
};
|
||||
const tsConfig = {
|
||||
input: input,
|
||||
output: {
|
||||
file: path.join(output, `./${lastDirectory}.d.ts`),
|
||||
format: 'esm',
|
||||
},
|
||||
plugins: [dts()],
|
||||
};
|
||||
return [buildConfig, tsConfig];
|
||||
})
|
||||
.flat();
|
||||
|
||||
export default [...configs];
|
||||
@@ -8,7 +8,8 @@
|
||||
"scripts": {
|
||||
"dev": "rollup -c -w",
|
||||
"build": "npm run clean && rollup -c",
|
||||
"pub": "envision switchOrg system && envision deploy ./deploy -v 0.0.1 -k ui -y y",
|
||||
"build:components": "rollup -c ./config/rollup.components.config.js",
|
||||
"pub": "envision switchOrg system && envision deploy ./dist -v 0.0.2 -k ui -y y",
|
||||
"clean": "rimraf dist"
|
||||
},
|
||||
"files": [
|
||||
@@ -21,7 +22,9 @@
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"dayjs": "^1.11.13",
|
||||
"glob": "^11.0.0",
|
||||
"lodash-es": "^4.17.21",
|
||||
"rollup-plugin-dts": "^6.1.1",
|
||||
"style-to-object": "^1.0.8"
|
||||
},
|
||||
"devDependencies": {
|
||||
|
||||
@@ -5,7 +5,7 @@ import postcss from 'rollup-plugin-postcss';
|
||||
import autoprefixer from 'autoprefixer';
|
||||
import cssnano from 'cssnano';
|
||||
import terser from '@rollup/plugin-terser';
|
||||
|
||||
import dts from 'rollup-plugin-dts';
|
||||
import postcssImport from 'postcss-import';
|
||||
|
||||
const isApps = process.env.TYPE === 'apps';
|
||||
@@ -13,29 +13,43 @@ const entrys = ['index'];
|
||||
/**
|
||||
* @type {import('rollup').RollupOptions[]}
|
||||
*/
|
||||
const configs = entrys.map((entry) => ({
|
||||
input: `./src/${entry}.ts`, // 修改输入文件为 TypeScript 文件
|
||||
output: {
|
||||
file: `./dist/${entry}.js`,
|
||||
// dir: 'dist',
|
||||
format: 'es', // 输出格式为 ES Module
|
||||
},
|
||||
plugins: [
|
||||
resolve({
|
||||
browser: true, // 处理浏览器版本的依赖
|
||||
}),
|
||||
commonjs(),
|
||||
typescript({
|
||||
tsconfig: './tsconfig.json',
|
||||
compilerOptions: {
|
||||
declaration: !isApps, // 生成声明文件
|
||||
declarationDir: './dist', // 声明文件输出目录
|
||||
// outDir: './types', //
|
||||
const configs = entrys
|
||||
.map((entry) => {
|
||||
const buildConfig = {
|
||||
input: `./src/${entry}.ts`, // 修改输入文件为 TypeScript 文件
|
||||
output: {
|
||||
file: `./dist/${entry}.js`,
|
||||
// dir: 'dist',
|
||||
format: 'es', // 输出格式为 ES Module
|
||||
},
|
||||
}), // 添加 TypeScript 插件
|
||||
terser(), // 压缩输出的 ES Module 文件
|
||||
],
|
||||
}));
|
||||
plugins: [
|
||||
resolve({
|
||||
browser: true, // 处理浏览器版本的依赖
|
||||
}),
|
||||
commonjs(),
|
||||
typescript({
|
||||
tsconfig: './tsconfig.json',
|
||||
compilerOptions: {
|
||||
// declaration: !isApps, // 生成声明文件
|
||||
declaration: false, // 生成声明文件
|
||||
declarationDir: './dist', // 声明文件输出目录
|
||||
// outDir: './types', //
|
||||
},
|
||||
}), // 添加 TypeScript 插件
|
||||
terser(), // 压缩输出的 ES Module 文件
|
||||
],
|
||||
};
|
||||
const dtsConfig = {
|
||||
input: `./src/${entry}.ts`,
|
||||
output: {
|
||||
file: `./dist/${entry}.d.ts`,
|
||||
format: 'esm',
|
||||
},
|
||||
plugins: [dts()],
|
||||
};
|
||||
return [buildConfig, dtsConfig];
|
||||
})
|
||||
.flat();
|
||||
|
||||
const entryCss = ['index'];
|
||||
const configsCss = entryCss.map((entry) => ({
|
||||
|
||||
Reference in New Issue
Block a user