Vue js babel ошибка сборки после установки prerender-spa-plugin - PullRequest
0 голосов
/ 27 ноября 2018

Итак, у меня есть приложение vue-js, и сегодня я начал использовать prerender-spa-plugin для генерации некоторых статических страниц для улучшения SEO.Когда я запускаю npm run 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-plugin, но все равно получаю ту же ошибку.Я надеюсь, что кто-то может указать мне правильное направление.

Мой babel.config.js

const removeConsolePlugin = []
if(process.env.NODE_ENV === 'production') {
 removeConsolePlugin.push("transform-remove-console")
 }


module.exports = {
 presets: [
'@vue/app'
],
  plugins: [removeConsolePlugin]
}

Мой vue.config.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);
    }
  }
}
...