underfin / vite-plugin-vue2

Vue2 plugin for Vite
620 stars 83 forks source link

Cannot config to compile SFC #173

Closed nntam2013 closed 2 years ago

nntam2013 commented 2 years ago

image I was trying to migrate from vue-cli to vite, but all my SFC doesn't work expectedly. My config:

export default defineConfig({
  plugins: [
    vue({
      jsx: true,
      vueTemplateOptions: {
        compilerOptions: {
          whitespace: 'preserve',
        },
      },
    }),
  ],
  server: {
    port: 8080,
    host: '0.0.0.0',
  },
  resolve: {
    alias: {
      web3: path.resolve(__dirname, './node_modules/web3/dist/web3.min.js'),
      '@': path.resolve(__dirname, './src'),
      vue: require.resolve('vue/dist/vue.js'),
    },
    extensions: ['.esm.js', '.cjs.js', '.js', '.ts', '.jsx', '.tsx', '.json'],
  },
  define: {
    // global: 'globalThis',
    'process.env': {},
  },
  optimizeDeps: {
    esbuildOptions: {
      // Node.js global to browser globalThis
      define: {
        global: 'globalThis',
      },
      // Enable esbuild polyfill plugins
      plugins: [
        NodeGlobalsPolyfillPlugin({
          process: true,
          buffer: true,
        }),
        NodeModulesPolyfillPlugin(),
      ],
    },
  },
  build: {
    rollupOptions: {
      plugins: [
        // Enable rollup polyfills plugin
        // used during production bundling
        rollupNodePolyFill(),
      ],
    },
  },
})