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>

猜你喜欢

转载自www.cnblogs.com/fewhj/p/11978773.html