我有一个使用vue-cli创建的vue项目。当运行yarn build
时,正常的输出是一个dist文件夹,其中包含一个index.html
文件和一个js和css子目录,其中包含相应的.js和.css文件。
我希望生成的构建输出是一个包含js和css的单个html文件。
我在项目根目录中添加了一个vue.config.js
文件,并将其设置为只输出单个js文件,这样可以正常工作。但我希望只有一个单独的html文件,其中包含js和任何已经存在于html文件中的css。
module.exports = {
css: {
extract: false,
},
configureWebpack: {
optimization: {
splitChunks: false
}
}
}
基本上,我希望我的HTML文件像这样:
<html lang=en>
<head>
... meta tags
<title>my title</title>
</head>
<body>
<div id=app></div>
<script>
// contents of the output js file here
</script>
</body>
</html>
这可行吗?
使用 Vue 3.9.3