Vue-cli / webpack 加载静态js文件的方法
2024-08-27 08:03:33
一、html-webpack-plugin 编译
1、只需要在入口处定义一个chunks,如我们定义一个fuck模块
entry: {
app: './src/main.js',
fuck: ['./src/utils/index.js', './src/utils/index2.js']
},
2、然后就可以在 html-webpack-plugin 插件配置处这样书写:
// https://github.com/ampedandwired/html-webpack-plugin
new HtmlWebpackPlugin({
filename: 'index.html',
template: 'index.html',
chunks: ['fuck'],
inject: true
}),
如果你使用的是vue-cli脚手架,那么在 webpack.dev.conf.js 、 webpack.prod.conf.js 都可以找到
二、如果你是使用vue-cli的脚手架
1、只需要将文件放入/static/中
2、然后在index.html中这样书写即可:
<script type="text/javascript" src="/static/fuck.js"></script>
最新文章
- dom 的介绍
- git stuff
- 关于OAUTH2.0的极品好文
- 自然语言6_treebank句子解析
- [Cocos2D-x For WP8]Label标签
- Python 深拷贝和浅拷贝
- TUXEDO错误解决方案
- gulp.watch监听文件
- iphone编程,使用代码结束程序
- ntpath join(path, *paths) 发生UnicodeDecodeError的Bug的解决方案
- contains选择器
- python中telnetlib模块的使用
- FusionCharts生成Flash图表常见问题FAQ
- spring mvc跨域(ajax post json)--filter方案
- 运行Myeclipse时,如何删除IVM窗口
- Python *args 和 **kwargs用法
- SSM框架整合(IntelliJ IDEA + maven + Spring + SpringMVC + MyBatis)
- 获取Ueditor里面的图片列表,地址绝对化
- 权限认证之OpenID-OP/RP
- jdk源码->;集合->;HashMap
热门文章
- iOS webservice SOAP 请求
- 通过16道练习学习Linq和Lambda
- MapReduce任务参数调优(转)
- go语言生成uuid
- jqPlot图表插件学习之数据节点高亮和光标提示
- excel单元格对齐方式
- 转 error while loading shared libraries: libmysqlclient.so.15: cannot open shared object file
- error:No buffer space available (maximum connections reached
- redis对key的基本操作
- asiHttpRequst 学习地址