vue-cli中 assetsPublicPath, assetsSubDirectory的區別


webpack配置代碼:

index: path.resolve(__dirname, ‘../dist/index.html‘),
assetsRoot: path.resolve(__dirname, ‘../dist‘),
assetsSubDirectory: ‘static‘,
assetsPublicPath: ‘./projectName‘

上述代碼的含義:

assetsRoot : 在當前目錄的上一級 的 dist目錄下輸出資源文件

assetsSubDirectory: 把所有的靜態資源打包到 dist下的 static文件夾下

assetsPublicPath :代表生成的index.html文件,里面引入資源時,路徑前面要加上 ./projectName/,也就是assetsPublicPath的值,即在index.html代碼中引用靜態文件:

<script type="text/javascript" src="./projectName/static/js/app.js"></script>


免責聲明!

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



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