How to generate files by vue and open them locally to view the effect
In this article Xiaobian for you to introduce in detail "vue how to generate file local open view effect", the content is detailed, the steps are clear, the details are handled properly, I hope this "vue how to generate file local open view effect" article can help you solve your doubts, the following follows the editor's train of thought slowly in depth, together to learn new knowledge.
Problem description:
After npm run build, the path for the direct browser to open index.html,css and js under the dist folder is incorrect. It's normal to put it in the directory.
Problem solving:
Open the config-index.js in the folder of the project
Just add a dot to the assetsPublicPath in the build section
AssetsPublicPath:'/
Change to
AssetsPublicPath:. /'
Explanation:
Change the absolute path to the relative path (the explanation is a little wrong, make do with it)
Extend:
The effect of this mainly affects the build- webpack.base.conf.js in the folder where the project is located.
The effect is equivalent to:
Output: {path: config.build.assetsRoot, filename:'[name] .js', publicPath: process.env.NODE_ENV = = 'production'? Config.build.assetsPublicPath: config.dev.assetsPublicPath}
Changed to:
Output: {path: config.build.assetsRoot, filename:'[name] .js', publicPath: process.env.NODE_ENV = 'production'?'. /': config.dev.assetsPublicPath}, this is the end of the article "how to generate files for local opening and viewing effect" article. If you want to master the knowledge points of this article, you still need to practice and use it yourself to understand it. If you want to know more about related articles, Welcome to the industry information channel.