zoukankan      html  css  js  c++  java
  • Vue-cli / webpack 加载静态js文件的方法

    一、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>
    
  • 相关阅读:
    WORD2003电子签名插件(支持手写、签章)
    苹果App部署HTTPS进行在线下载安装
    解决安卓SDK更新连不通问题
    部署rfc5766-turn-server--谷歌推荐的开源穿透服务器 [复制链接]
    实测可用的免费STUN服务器!
    seajs加载jquery时提示$ is not a function该怎么解决
    tomcat发布web service教程
    Java WebService 简单实例
    HTML 5 断点续上传
    MySQL said: Authentication plugin 'caching_sha2_password' cannot be loaded
  • 原文地址:https://www.cnblogs.com/CyLee/p/9888473.html
Copyright © 2011-2022 走看看