最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - What is best way to include external js files in (webpack and vue2) - Stack Overflow

programmeradmin3浏览0评论

I just developed the project using webpack2 and vue2. I have other external plugins which cannot be installed through npm. So my question is the best way to include these files. Here are my index.html

<html>
     <head>
     </head>
     <body>
     <div id="app"></div> 
     <script src="app.js"></script>
     <script src="/static/js/flowchart.js"></script>
     <script src="/static/js/exteral2.js"></script>
    </body>
</html>

this is my index.html whare I include some external js files. Can we do some bundling so that we dont need to include these external files to index.html or this is the only way to include external js files.

Any help would be highly appreciated. Thanks

I just developed the project using webpack2 and vue2. I have other external plugins which cannot be installed through npm. So my question is the best way to include these files. Here are my index.html

<html>
     <head>
     </head>
     <body>
     <div id="app"></div> 
     <script src="app.js"></script>
     <script src="/static/js/flowchart.js"></script>
     <script src="/static/js/exteral2.js"></script>
    </body>
</html>

this is my index.html whare I include some external js files. Can we do some bundling so that we dont need to include these external files to index.html or this is the only way to include external js files.

Any help would be highly appreciated. Thanks

Share Improve this question asked Jan 5, 2018 at 12:26 Amit SharmaAmit Sharma 2,4873 gold badges21 silver badges26 bronze badges 1
  • Possible duplicate of How to include external file with webpack – Liam Commented Jan 5, 2018 at 12:41
Add a ment  | 

2 Answers 2

Reset to default 1

Include external file in code with relative path:

import './static/js/flowchart.js';

Usually you can do this by just importing the external js files into your *.vue file like this:

import './external/js/.js';

But in Webpacka you need to not parse these files as modules:
https://github./webpack/webpack.js/issues/63

发布评论

评论列表(0)

  1. 暂无评论