1

Once you've compiled a bunch of Vue single file components into a single JS file, is there a way to use them from vanilla JS (ES5) in the browser to dynamically insert them on the page?

I found a tool that compiles the SFC's to JS here: https://github.com/RonnieSan/vue-browser-sfc

...but you have to compile each component into a separate .js file.

So is there a way to use Webpack to compile the distribution .js file and make all the single file components accessible from the browser?

Eg.

<html lang="en">
<head>
    <script src="/dist/index.js"></script>
</head>
<body>
    <div id="wrapper">
      <my-component></my-component>
    </div>
    <script>
    var app = new Vue({
      el : '#wrapper'
    });
    
    // How do I access the MyComponent object?
    </script>
</body>
</html>
DFx
  • 249
  • 3
  • 14
  • Maybe [this answer](https://stackoverflow.com/questions/48442598/can-we-make-vue-js-application-without-vue-extension-component-and-webpack) can help – ljubadr Jul 12 '20 at 04:03
  • Thanks, but it'd still like to use Webpack so that .vue files are compiled efficiently and I can use SCSS processing, etc. I'd like to have all the components compiled into a single JS file too. – DFx Jul 12 '20 at 11:30

0 Answers0