Skip to content

Pinia in Vite library build #2051

Closed Answered by dcrall
dcrall asked this question in Help and Questions
Discussion options

You must be logged in to vote

I got this working by following the model I had for Vue. Here's my working vite.config

import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'

export default defineConfig({
  plugins: [vue()],

  resolve: {
    alias: {
      ...
      'vue': 'vue/dist/vue.esm-bundler.js',
      'pinia': 'pinia/dist/pinia.esm-browser.js',
      'vue-router': 'vue-router/dist/vue-router.esm-bundler.js'
    }
  },

  define: {
    'process.env.NODE_ENV': '"production"'
  },

  build: {
    lib: {
      entry: '/src/viewer.js',
      name: 'viewer',
      formats: ['es', 'umd'],
      fileName: (format, alias) => `${alias}.${format}.js`,
    },

    rollupOptions: {
      external: [
        

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by dcrall
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
1 participant