最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Why is the file `vite.svg` in the `dist` folder when building with Vite library mode? - Stack Overflow

programmeradmin2浏览0评论

I am trying to publish a React ponent as an npm module using the library mode of Vite. But even though my entry file does not import or use the image vite.svg it is copied to the dist folder.

vite.config.js:

export default defineConfig({
  plugins: [react()],
  build: {
    lib: {
      // Could also be a dictionary or array of multiple entry points
      entry: resolve(__dirname, 'src/index.jsx'),
      name: 'MyLib',
      // the proper extensions will be added
      fileName: 'my-lib',
    },
    rollupOptions: {
      // make sure to externalize deps that shouldn't be bundled
      // into your library
      external: ['react', 'react-dom'],
      output: {
        // Provide global variables to use in the UMD build
        // for externalized deps
        globals: {
          react: 'React',
          'react-dom': 'ReactDOM',
        },
      },
    },
  },
})

src/index.jsx:

import React from 'react';

export function Button(props) {
  return <button {...props} />;
}

dist

发布评论

评论列表(0)

  1. 暂无评论