修改vue+webpack run build的路徑方法
vue項(xiàng)目用webpack打包想要修改靜態(tài)資源路徑等,找到項(xiàng)目根目錄下的config文件夾,打開(kāi)該文件夾下的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)上的絕對(duì)路徑。會(huì)生成index.html文件。
build.assetsRoot:必須是本地文件系統(tǒng)上的絕對(duì)路徑。
build.assetsSubDirectory:編譯出來(lái)的資源文件。
build.assetsPublicPath:【資源的根目錄】,這是通過(guò)http服務(wù)器運(yùn)行的url路徑。默認(rèn)情況下,是根目錄(/)。如果后臺(tái)對(duì)靜態(tài)資源url前綴要求,則需要改變這個(gè)路徑。
build.productionSourceMap:在構(gòu)建生產(chǎn)環(huán)境版本時(shí)是否開(kāi)啟source map。
以上這篇修改vue+webpack run build的路徑方法就是小編分享給大家的全部?jī)?nèi)容了,希望能給大家一個(gè)參考,也希望大家多多支持腳本之家。
相關(guān)文章
Element?ui中menu組件(el-menu/el-menu-item/el-submenu/template)
最近在使用Element開(kāi)發(fā)時(shí)遇到了不少問(wèn)題,下面這篇文章主要給大家介紹了關(guān)于Element?ui中menu組件(el-menu/el-menu-item/el-submenu/template)層級(jí)結(jié)構(gòu)與用法的相關(guān)資料,需要的朋友可以參考下2022-12-12
vue實(shí)現(xiàn)垂直無(wú)限滑動(dòng)日歷組件
這篇文章主要為大家詳細(xì)介紹了vue實(shí)現(xiàn)垂直無(wú)限滑動(dòng)日歷組件,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2022-04-04
vue實(shí)現(xiàn)定時(shí)刷新數(shù)據(jù),每隔5分鐘執(zhí)行一次
這篇文章主要介紹了vue實(shí)現(xiàn)定時(shí)刷新數(shù)據(jù),每隔5分鐘執(zhí)行一次問(wèn)題,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教2023-01-01
vue3引入highlight.js進(jìn)行代碼高亮的方法實(shí)例
最近忙著開(kāi)發(fā)自己的開(kāi)發(fā)腳手架,在做代碼生成器的時(shí)候,有個(gè)預(yù)覽功能,需要讓代碼高亮,下面這篇文章主要給大家介紹了關(guān)于vue3引入highlight.js進(jìn)行代碼高亮的相關(guān)資料,需要的朋友可以參考下2022-04-04
Vue前端如何設(shè)置Cookie和鑒權(quán)問(wèn)題詳解
這篇文章主要介紹了前端如何設(shè)置和使用Cookie,并對(duì)比了Cookie和Token在鑒權(quán)中的優(yōu)缺點(diǎn),文中通過(guò)代碼介紹的非常詳細(xì),需要的朋友可以參考下2025-02-02

