PNPM, NPM 등 패키지 매니저를 통해서 빌드를 할 때 결과물 상단에 banner를 넣고 싶을 때 필요한 옵션이다.
vite.config.js
rollupOptions: {
// external modules won't be bundled into your library
external: ["vue"], // not every external has a global
output: {
banner: `
/**
* Copyright ${new Date(Date.now()).getFullYear()} My Company
* @license MIT
**/
`,
// disable warning on src/index.ts using both default and named export
exports: "named",
// Provide global variables to use in the UMD build
// for externalized deps (not useful if 'umd' is not in lib.formats)
globals: {
vue: "Vue",
},
},
},
dist/my-lib.cjs.js
"use strict";/**
* Copyright 2023 My Company
* @license MIT
**/Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const a=require("vue"),
...
좋은 글 감사합니다.