chore: 修改 es 为 esm 包
This commit is contained in:
parent
09ea8472ab
commit
c9ceb42b46
@ -20,11 +20,10 @@
|
|||||||
"import": "./esm/index.js"
|
"import": "./esm/index.js"
|
||||||
},
|
},
|
||||||
"./lib/": "./lib/",
|
"./lib/": "./lib/",
|
||||||
"./es/": "./es/"
|
"./esm/": "./esm/"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "npm run build:all && npm run build:es && npm run build:esm && npm run build:umd && npm run build:types",
|
"build": "npm run build:all && npm run build:esm && npm run build:umd && npm run build:types",
|
||||||
"build:es": "vite build --emptyOutDir --config ./script/build.es.ts",
|
|
||||||
"build:esm": "vite build --emptyOutDir --config ./script/build.esm.ts",
|
"build:esm": "vite build --emptyOutDir --config ./script/build.esm.ts",
|
||||||
"build:all": "vite build --emptyOutDir --config ./script/build.all.ts",
|
"build:all": "vite build --emptyOutDir --config ./script/build.all.ts",
|
||||||
"build:umd": "vite build --emptyOutDir --config ./script/build.umd.ts",
|
"build:umd": "vite build --emptyOutDir --config ./script/build.umd.ts",
|
||||||
@ -60,7 +59,7 @@
|
|||||||
},
|
},
|
||||||
"files": [
|
"files": [
|
||||||
"lib",
|
"lib",
|
||||||
"es",
|
"esm",
|
||||||
"umd",
|
"umd",
|
||||||
"types"
|
"types"
|
||||||
],
|
],
|
||||||
|
@ -1,67 +0,0 @@
|
|||||||
import { UserConfigExport } from "vite";
|
|
||||||
import vue from "@vitejs/plugin-vue";
|
|
||||||
import { resolve } from "path";
|
|
||||||
import * as fs from "fs";
|
|
||||||
|
|
||||||
const inputDir = resolve(process.cwd(), "./src/component");
|
|
||||||
|
|
||||||
const inputsArray = fs.readdirSync(inputDir).filter((name) => {
|
|
||||||
const componentDir = resolve(inputDir, name);
|
|
||||||
const isDir = fs.lstatSync(componentDir).isDirectory();
|
|
||||||
return isDir && fs.readdirSync(componentDir).includes("index.ts");
|
|
||||||
});
|
|
||||||
|
|
||||||
const inputs = inputsArray.reduce((backObj, pkgName) => {
|
|
||||||
backObj[pkgName] = resolve(
|
|
||||||
process.cwd(),
|
|
||||||
`./src/component/${pkgName}/index.ts`
|
|
||||||
);
|
|
||||||
return backObj;
|
|
||||||
}, {});
|
|
||||||
|
|
||||||
inputs["index"] = resolve(process.cwd(), "./src/index.ts");
|
|
||||||
|
|
||||||
export default (): UserConfigExport => {
|
|
||||||
return {
|
|
||||||
publicDir: false,
|
|
||||||
resolve: {
|
|
||||||
alias: [
|
|
||||||
{
|
|
||||||
find: "@",
|
|
||||||
replacement: resolve(process.cwd(), "./"),
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
css: {
|
|
||||||
preprocessorOptions: {
|
|
||||||
less: {
|
|
||||||
javascriptEnabled: true,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
postcss: {},
|
|
||||||
},
|
|
||||||
plugins: [vue()],
|
|
||||||
build: {
|
|
||||||
cssCodeSplit: true,
|
|
||||||
emptyOutDir: true,
|
|
||||||
outDir: "es",
|
|
||||||
lib: {
|
|
||||||
entry: "./index.ts",
|
|
||||||
formats: ["es"],
|
|
||||||
},
|
|
||||||
rollupOptions: {
|
|
||||||
input: inputs,
|
|
||||||
output: {
|
|
||||||
globals: {
|
|
||||||
vue: "Vue",
|
|
||||||
},
|
|
||||||
entryFileNames: ({ name }) => {
|
|
||||||
return name === "index" ? "index.js" : "[name]/index.js";
|
|
||||||
},
|
|
||||||
assetFileNames: "[name]/index.css",
|
|
||||||
},
|
|
||||||
external: ["vue", "vue-router"],
|
|
||||||
},
|
|
||||||
},
|
|
||||||
};
|
|
||||||
};
|
|
@ -60,8 +60,6 @@ export default (): UserConfigExport => {
|
|||||||
vue: "Vue",
|
vue: "Vue",
|
||||||
},
|
},
|
||||||
manualChunks(id) {
|
manualChunks(id) {
|
||||||
console.log("mmmmm",id);
|
|
||||||
|
|
||||||
let arr = id.toString().split('/');
|
let arr = id.toString().split('/');
|
||||||
if (id.includes('node_modules')) {
|
if (id.includes('node_modules')) {
|
||||||
//id => layui-vue/node_modules/.pnpm/@vue+devtools-api@6.1.4/node_modules/@vue/devtools-api/lib/esm/api/app.js
|
//id => layui-vue/node_modules/.pnpm/@vue+devtools-api@6.1.4/node_modules/@vue/devtools-api/lib/esm/api/app.js
|
||||||
|
@ -324,7 +324,7 @@ export interface LayuiVueResolverOptions {
|
|||||||
const libRE = /^Lay[A-Z]/;
|
const libRE = /^Lay[A-Z]/;
|
||||||
const layerRE = /^(layer|LayLayer)$/;
|
const layerRE = /^(layer|LayLayer)$/;
|
||||||
const iconsRE = /^([A-Z][\w]+Icon|LayIcon)$/;
|
const iconsRE = /^([A-Z][\w]+Icon|LayIcon)$/;
|
||||||
const esComponentsFolder = "@layui/layui-vue/es";
|
const esComponentsFolder = "@layui/layui-vue/esm";
|
||||||
|
|
||||||
function lowerCamelCase(str: string) {
|
function lowerCamelCase(str: string) {
|
||||||
return str.charAt(0).toLowerCase() + str.slice(1);
|
return str.charAt(0).toLowerCase() + str.slice(1);
|
||||||
|
Loading…
Reference in New Issue
Block a user