Work with output.globals option
loliconer opened this issue · comments
少司命 commented
import Vue from 'vue'
new Vue({
}).$mount('#app')
In the bundle file, Vue
is compiled to vue
.
eight commented
Have you specified the variable name in your configuration?
少司命 commented
Yes, this is my config:
export default {
input: [
'src/main.js'
],
output: {
format: 'es',
dir: 'public/js',
globals: {
vue: 'Vue'
}
},
external: ['vue'],
plugins: [
iife()
],
experimentalCodeSplitting: true
}
And the compiled content:
(function () {
new vue({
}).$mount('#app');
})();
eight commented
iife
plugin doesn't use output.globals
, it has its own variable name map:
export default {
input: [
'src/main.js'
],
output: {
format: 'es',
dir: 'public/js'
},
external: ['vue'],
plugins: [
iife({
names: {
vue: 'Vue'
}
})
],
experimentalCodeSplitting: true
}
I guess we should support output.globals
as well.
少司命 commented
Thanks.
Yes, it will be better to support output.globals
. Otherwise I have to config this option twice.