我正在尝试在我的生产环境中构建站点Map,并且我一直在尝试使用站点Map网页包插件,但出现以下错误:
ERROR in TypeError: compilation.emitAsset is not a function
at /Users/ME/Sites/test-site/node_modules/sitemap-webpack-plugin/lib/index.js:378:41
at Array.forEach (<anonymous>)
at SitemapWebpackPlugin.<anonymous> (/Users/ME/Sites/test-site/node_modules/sitemap-webpack-plugin/lib/index.js:377:34)
at step (/Users/ME/Sites/test-site/node_modules/sitemap-webpack-plugin/lib/index.js:86:23)
at Object.next (/Users/ME/Sites/test-site/node_modules/sitemap-webpack-plugin/lib/index.js:67:53)
at fulfilled (/Users/ME/Sites/test-site/node_modules/sitemap-webpack-plugin/lib/index.js:57:58)
my package.json:
"sitemap-webpack-plugin": "^1.1.0",
"webpack": "4.28.0",
在我的webpack.prod中:
const SitemapPlugin = require('sitemap-webpack-plugin').default;
const paths = ['url/', 'url/url2'];
// later down the file inside plugins:
new SitemapPlugin({ base: 'https://www.bob.com', paths })
当我使用Webpack4时,我认为emitasset应该工作吗?
还有其他人见过这个吗?
1条答案
按热度按时间oyjwcjzk1#
compilation.emitAsset
从webpack 4.40.0开始提供,请参阅https://webpack.js.org/api/compilation-object/#emitasset,这意味着您可能需要先升级您的网页包。