是否可以使用自定义VueJS dist文件夹位置?

Pre*_*cks 2 deployment vuejs2

要部署VueJS应用程序,请运行 npm run build

这会在您的开发者应用结构中创建一个dist文件夹.是否可以更改创建此dist文件夹的位置.

我使用webpack模板创建了我的VueJS应用程序 vue init webpack app-name

yur*_*636 7

在vue webpack模板中,您可以更改config/index.js文件中的路径:

  build: {
    [...]
    index: path.resolve(__dirname, '../dist/index.html'),
    assetsRoot: path.resolve(__dirname, '../dist'),
    [...]
  },
Run Code Online (Sandbox Code Playgroud)

将两行都更改为(对于绝对路径):

index: path.resolve('/www/dist/index.html'),
assetsRoot: path.resolve('/www/dist'),
Run Code Online (Sandbox Code Playgroud)

或者,对于一个亲戚:

index: path.resolve(__dirname, '../deploy/public_html/index.html'),
assetsRoot: path.resolve(__dirname, '../deploy/public_html'),
Run Code Online (Sandbox Code Playgroud)

如果您在Windows环境中,可以使用上述格式或'C:\\www'类似(只需确保逃避\)

path.resolve 文档