Closed diegoazh closed 2 years ago
I solved my issue by adding the following configuration to .vuepress/config.js
const HtmlWebpackPlugin = require("html-webpack-plugin");
const HtmlWebpackInlineSourcePlugin = require("html-webpack-inline-source-plugin");
module.exports = {
...
configureWebpack: (config, isServer) => {
configureWebpack: (config) => {
return {
plugins: [
new HtmlWebpackPlugin(),
new HtmlWebpackInlineSourcePlugin(HtmlWebpackPlugin),
],
};
};
},
};
This issue is SOLVED!!!
UPDATE 2022-02-10
Unfortunately, the issue persists on GitHub actions and the build always fails.
I debugged the process and I don't know the vue-server-renderer
package is using webpack 5.68.0
and becuase of that
compilation.hooks.processAssets
is undefined
I think this is because in one of the pacakges of the monorepo I had installed webpack 5 and vuepress install webpack 4, but I'm not sure.
Ok, the problem was due to I was using different versions of Webpack in different packages of the mono-repo, as a workaround inside GitHub actions I remove the pnpm workspace file then run install inside the package itself and then executes the build process of Vuepress.
How this problem is not related to Vuepress it can be considered as resolved.
Note: finally I removed the HtmlWebpackPlugin
and HtmlWebpackInlineSourcePlugin
from the package.json
and the Vuepress config file.
Facing the same error in pnpm workspace too...
It can be solved with the webpack version under “webpack@^5.0.0”
you will need to use the workaround, is something annoying but it works.
I had this problem (caused by a monorepo that used Webpack 5), but easily solved it by installing webpack@4
as part of my GH workflow:
I had this problem (caused by a monorepo that used Webpack 5), but easily solved it by installing
webpack@4
as part of my GH workflow:
The @xon52 solution solved my problem too. Really Thanks for the contribution
没有一大陆人遇到这个问题吗?
@diegoazh Hi, is there a pnpm issue related to this?
@ziofat maybe, but I don't think so.
After digging up, I believe this is not because of pnpm. If you are using pnpm workspace and have webpack 5 installed in another package, the vue-server-renderer
will resolve to webpack 5.
vue-server-renderer
has require('webpack')
in its generated code but it does not have webpack in its package.json
dependencies, which causes it to resolve to webpack installed by another package, and automatically detect the version as 5 and use v5 APIs which are not compatible with VuePress.
The issue should be address by vue-server-renderer
itself which is generated in Vue, because it has irregular package.json
.
A workaround is using pnpmfile.js
to add the dependency:
function readPackage(packageJson, context) {
if (packageJson.name === 'vue-server-renderer') {
packageJson.dependencies['webpack'] = '^4.0.0';
}
return packageJson;
}
npm i vue-server-renderer@2.5.22 -D
I had this problem (caused by a monorepo that used Webpack 5), but easily solved it by installing
webpack@4
as part of my GH workflow:
I fixed the same problem with this method.
Bug report
Steps to reproduce
clone the repository
[gmap-vue](https://github.com/diegoazh/gmap-vue)
and runpnpm install
andpnpm run build
What is expected?
Build without errors.
What is actually happening?
It throws the above error when you run
vuepress build docs
Other relevant information
The bug brokes the build process, I think is something related to webpack or vue-server-renderer, the above output is the error throwed by vuepress when I run
vuepress build docs
, I'm using pnpm as a package manager and when I include"webpack":"~4.0.0"
in thepackage.json
it works for the first time but if I run againpnpm install
at the root level (the project is a monorepo) in the next execution ofvuepress build docs
it fails with the above error. Another detail is that I'm using my package in the vuepress repo, I mean"gmap-vue": "worspace:../gmap-vue"
and that package is using webpack 5; I'm not sure if that can be a problem but is another important detail. Another interesting detail is thatvuepress dev docs
works well without throwing errors.npx vuepress info
in my VuePress project: