vuejs / vue-loader

📦 Webpack loader for Vue.js components
MIT License
4.99k stars 915 forks source link

How to compile vue2 file and vue3 file #1816

Closed BlackCubeNo99 closed 3 years ago

BlackCubeNo99 commented 3 years ago

What is the current behavior? Cannot compile Vue2 and Vue3 at the same time

If the current behavior is a bug, please provide the steps to reproduce. I installed vue-loadervue-template-compiler@vue/compiler-sfcvue2vue3

// package.json
"devDependencies": {
  "vue-loader": "16.1.2",
  "vue-template-compiler": "2.6.12",
  "@vue/compiler-sfc": "3.0.7"
},
"dependencies": {
  "vue": "2.6.12",
  "vue3": "npm:vue@3.0.7"
}

How to set vue2 and vue3 config ?

// webpack.config.js
module.exports = {
  entry: ['a.js', 'b.ts'],
  resolve: {
    alias: {}
  }
}

a.js use vue2

// a.js
import Vue from 'vue'
import App from './App.vue'

new Vue({
  el: '#app',
  render: h => h(App)
})

b.ts use vue3

// b.ts
import { createApp } from 'vue3'
import App from './App.vue'

createApp(App).mount('#app')

What is the expected behavior? compile Vue2 and Vue3 at the same time

Other relevant information: webpack version: 5.24.4 Node.js version: 12.16.2 Operating System: macOS Catalina 10.15.7 Additional tools:

vue-bot commented 3 years ago

Hello, thank you for taking time filling this issue!

However, we kindly ask you to use our Issue Helper when creating new issues, in order to ensure every issue provides the necessary information for us to investigate. This explains why your issue has been automatically closed by me (your robot friend!).

I hope to see your helper-created issue very soon!