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>
    
  • 相关阅读:
    递归算法的时间复杂度
    5分钟了解lucene全文索引
    Codeforces Round #234A
    快速排序法
    构造方法、类的初始化块以及类字段的初始化顺序
    Java之方法重载篇(我重载了,你要如何来调用我。。)
    突如其来的&amp;quot;中断异常&amp;quot;,我(Java)该如何处理?
    一个简单的wed服务器SHTTPD(4)————SHTTPD支持CGI的实现
    一个简单的wed服务器SHTTPD(3)————SHTTPD多客户端支持的实现
    一个简单的wed服务器SHTTPD(2)———— 客户端请求分析
  • 原文地址:https://www.cnblogs.com/CyLee/p/9888473.html
Copyright © 2011-2022 走看看