修改vue+webpack run build的路徑方法
vue項目用webpack打包想要修改靜態(tài)資源路徑等,找到項目根目錄下的config文件夾,打開該文件夾下的index.js文件,默認(rèn)如下:
// see http://vuejs-templates.github.io/webpack for documentation. var path = require('path') module.exports = { build: { env: require('./prod.env'), index: path.resolve(__dirname, '../dist/index.html'), assetsRoot: path.resolve(__dirname, '../dist'), assetsSubDirectory: 'static', assetsPublicPath: '/', productionSourceMap: true, // Gzip off by default as many popular static hosts such as // Surge or Netlify already gzip all static assets for you. // Before setting to `true`, make sure to: // npm install --save-dev compression-webpack-plugin productionGzip: false, productionGzipExtensions: ['js', 'css'], // Run the build command with an extra argument to // View the bundle analyzer report after build finishes: // `npm run build --report` // Set to `true` or `false` to always turn it on or off bundleAnalyzerReport: process.env.npm_config_report }, dev: { env: require('./dev.env'), port: 8080, autoOpenBrowser: true, assetsSubDirectory: 'static', assetsPublicPath: '/', proxyTable: {}, // CSS Sourcemaps off by default because relative paths are "buggy" // with this option, according to the CSS-Loader README // (https://github.com/webpack/css-loader#sourcemaps) // In our experience, they generally work as expected, // just be aware of this issue when enabling this option. cssSourceMap: false } }
其中build.index:必須是本地文件系統(tǒng)上的絕對路徑。會生成index.html文件。
build.assetsRoot:必須是本地文件系統(tǒng)上的絕對路徑。
build.assetsSubDirectory:編譯出來的資源文件。
build.assetsPublicPath:【資源的根目錄】,這是通過http服務(wù)器運行的url路徑。默認(rèn)情況下,是根目錄(/)。如果后臺對靜態(tài)資源url前綴要求,則需要改變這個路徑。
build.productionSourceMap:在構(gòu)建生產(chǎn)環(huán)境版本時是否開啟source map。
以上這篇修改vue+webpack run build的路徑方法就是小編分享給大家的全部內(nèi)容了,希望能給大家一個參考,也希望大家多多支持腳本之家。
相關(guān)文章
VUE3基于vite封裝條形碼和二維碼組件的詳細(xì)過程
基礎(chǔ)組件開發(fā)是項目業(yè)務(wù)開發(fā)的基石, 本文主要介紹了通過vue3的vite腳手架快速搭建項目, 開發(fā)條形碼和二維碼組件的過程,感興趣的朋友跟隨小編一起看看吧2023-08-08前端vue3打印功能實現(xiàn)(多頁打印、不使用插件)
在Vue項目中實現(xiàn)打印功能是前端開發(fā)中常見需求之一,這篇文章主要介紹了前端vue3打印功能實現(xiàn)的全部過程,文中介紹的方法實現(xiàn)了多頁打印并且不使用插件,需要的朋友可以參考下2024-09-09<el-button>點擊后如何跳轉(zhuǎn)指定url鏈接
這篇文章主要介紹了<el-button>點擊后如何跳轉(zhuǎn)指定url鏈接問題,具有很好的參考價值,希望對大家有所幫助。如有錯誤或未考慮完全的地方,望不吝賜教2023-04-04Vue+Element-UI中el-table動態(tài)合并單元格:span-method方法代碼詳解
el-table是element-ui提供的表格組件,可以用于展示和操作數(shù)據(jù),這篇文章主要給大家介紹了關(guān)于Vue+Element-UI中el-table動態(tài)合并單元格:span-method方法的相關(guān)資料,需要的朋友可以參考下2023-09-09Vue使用fabric.js實現(xiàn)局部截圖與大圖預(yù)覽功能
這篇文章主要為大家詳細(xì)介紹了Vue如何使用fabric.js實現(xiàn)局部截圖與el-image-viewer大圖預(yù)覽功能,文中的示例代碼講解詳細(xì),感興趣的可以了解下2024-02-02