在开发模式下构建时指定资产输出目录
Specify the assets output directory when building in development mode
我正在使用 Vue CLI 将我的应用程序构建到我现有的 php 项目之一中。如果要使用 php 中生成的文件,我需要将资产移动到 ../public/assets/
目录。不幸的是,这似乎在开发环境中不起作用(生产模式工作得很好,但我真的需要在 php 应用程序中测试 vue 的集成)。
我是做错了什么还是已知限制?
配置如下:
// vue.config.js
module.exports = {
outputDir: '../public',
assetsDir: './assets',
indexPath: './views/index.html'
};
根据文档,您只需将 assets
复制到您的 public/assets
文件夹并通过绝对路径引用它们。
https://cli.vuejs.org/guide/html-and-static-assets.html#static-assets-handling
Static assets can be handled in two different ways:
Imported in JavaScript or referenced in templates/CSS via relative paths. Such references will be handled by webpack.
Placed in the public directory and referenced via absolute paths. These assets will simply be copied and not go through webpack.
由于 HMR 处于开发模式,目前还无法实现。这是 Vue.js 论坛上的 reference to the communication。
我正在使用 Vue CLI 将我的应用程序构建到我现有的 php 项目之一中。如果要使用 php 中生成的文件,我需要将资产移动到 ../public/assets/
目录。不幸的是,这似乎在开发环境中不起作用(生产模式工作得很好,但我真的需要在 php 应用程序中测试 vue 的集成)。
我是做错了什么还是已知限制?
配置如下:
// vue.config.js
module.exports = {
outputDir: '../public',
assetsDir: './assets',
indexPath: './views/index.html'
};
根据文档,您只需将 assets
复制到您的 public/assets
文件夹并通过绝对路径引用它们。
https://cli.vuejs.org/guide/html-and-static-assets.html#static-assets-handling
Static assets can be handled in two different ways:
Imported in JavaScript or referenced in templates/CSS via relative paths. Such references will be handled by webpack.
Placed in the public directory and referenced via absolute paths. These assets will simply be copied and not go through webpack.
由于 HMR 处于开发模式,目前还无法实现。这是 Vue.js 论坛上的 reference to the communication。