Compile the .vue file into a .js file without webpack or scroll

Is there a way to compile a .vue file into a .js file without webpack or render a browser? I know the kindness of a webpack or browser, but I just need the easiest way to compile the .vue file. For example, I have one component of the comp.vue file that was executed in comp.js (the compiler must compile sass and pug in the .vue file), and then I can use it in my application, as shown below:

 <head> <script src="vue.min.js"></script> <script src="comp.js"></script> //it may pack the whole component into variable comp and add the style <script> Vue.component('comp', comp); window.onload = function() { new Vue({el: '#app'}); } </script> </head> <body id='app'> <comp></comp> </body> 

or another similar / simpler way?

+5
source share
1 answer

The vue-cli tool (version 2.8.0) contains a build command that you can use to create a separate component.

 vue build Component.vue --prod --lib 

This will create an optimized package in UMD format, and the name of the exported library is set to Component, you can use --lib [CustomLibraryName] to configure it.

You can take the inline script and include it in your file, as in your question. Technically, it uses webpack under the hood, but you don't need to configure anything.

+7
source

All Articles