所以我有一个vue js应用程序,今天我开始使用prerender spa插件生成一些静态页面,以更好地进行SEO。当我运行npm运行build时,一切都很完美,没有错误。现在,当我想用npm run serve运行开发服务器时,我得到了以下错误(只是其中的一部分)
error in ./src/main.js
Module build failed (from ./node_modules/babel-
loader/lib/index.js):
Error: .plugins[0] must include an object
at assertPluginItem (/Users/user/Desktop/app/node_modules/@babel/core/lib/config/validation/option-assertions.js:231:13)
所以我猜问题与babel插件加载程序有关。所以我推荐使用prerender spa插件的代码的每一部分,但我仍然会遇到同样的错误。我希望有人能给我指出正确的方向。
我的宝贝。配置。js
const removeConsolePlugin = []
if(process.env.NODE_ENV === 'production') {
removeConsolePlugin.push("transform-remove-console")
}
module.exports = {
presets: [
'@vue/app'
],
plugins: [removeConsolePlugin]
}
我的vue。配置。js
const path = require('path');
const PrerenderSpaPlugin = require('prerender-spa-plugin');
const productionPlugins = [
new PrerenderSpaPlugin({
staticDir: path.join(__dirname, 'dist'),
routes: ['/', '/documentation'],
renderer: new PrerenderSpaPlugin.PuppeteerRenderer({
// We need to inject a value so we're able to
// detect if the page is currently pre-rendered.
inject: {},
// Our view component is rendered after the API
// request has fetched all the necessary data,
// so we create a snapshot of the page after the
// `data-view` attribute exists in the DOM.
//renderAfterElementExists: '[data-view]',
}),
}),
];
module.exports = {
configureWebpack: (config) => {
if (process.env.NODE_ENV === 'production') {
config.plugins.push(...productionPlugins);
}
}
}