layers support for vite,quickly inherit your vite configuration
I want to inherit the configuration of the vite project in workspace and npm package
- inherit configuration file
- npm package
- relative position
npm i vite-layers -D
// vite.config.ts
import { Layers } from "vite-layers";
export default Layers({
// Your own vite configuration now
vite: {
server: {
port: 3000,
},
},
extends: "../vite-vue", // The target directory you want to inherit
});
import Config from "../vite-vue/vite.config.ts"; // Manual Import Config
// vite.config.ts
import { Layers } from "vite-layers";
export default Layers({
extends: Config, // The target directory you want to inherit
});
// vite.config.ts
import Config from "../vite-vue/vite.config.ts"; // Manual Import Config
import { Layers } from "vite-layers";
export default Layers({
extends: [
"../../vite-vue",
Config,
], // Multiple target directories to inherit
});
// vite.config.ts
import { Layers } from "vite-layers";
export default Layers({
normalize(config) {
// Allows you to modify the final configuration
return config;
},
extends: [
"../../vite-vue",
],
});
// vite.config.ts
import { Layers } from "vite-layers";
export default Layers({
extends: [
"package", // your package
],
});
If you are using TS and there is tsconfig.node.json
, you need to add types
{
"compilerOptions": {
"types": ["vite"] // add vite
// ...other content
}
}
Inspired by nuxt/layers
Made with markthree
Published under MIT License.