iview-cli 采坑記錄


1.iview-cli 關於跨域的問題: 使用 webpack-devServer 啟動 node 服務器可以通過配置 proxy 對象實現跨域:


let proxyUrl = 'http://dev.api.wankaonline.gm825.net';

devServer: {
    proxy: {
        '/index': {
		target: proxyUrl,
		pathRewrite: {'^/index' : '/index'},
		ws: true,
		changeOrigin: true,
	},  
        ...      

    }
}

2.打包后文件不加 hash 值,如下修改 :


        filename: '[name].[hash].js',
        chunkFilename: '[name].[hash].chunk.js'

       去掉 filename 和  chunkFilename 的  " [hash] " 就可以了。

3.自動生成的 html 文件 中 引入 css 和 js 文件時 ,加后綴 hash 值:

     webpack配置的 plugins 里面找到 HtmlWebpackPlugin 插件 ,如下配置即可
        
    new HtmlWebpackPlugin({
            filename: '../index_prod.html',
            template: './src/template/index.ejs',
            inject: false,
            // html 文件 引入 js 、 css 增加 hash后綴
            hash : true
        })


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM