更新到 v2.15 后,NuxtJs 开发构建中断了

问题描述 投票:0回答:1

我最近将旧的 nuxtjs 项目从 1.4.5 更新到 2.12.0,这样我就可以利用公共和私有运行时配置。一切似乎都正常,直到它尝试完成构建客户端捆绑包,我收到此错误

 ERROR  Failed to compile with 1 errors                                                                                                                           

This relative module was not found:  
                                                                                                                             
* ./blank.vue?vue&type=template&id=082ee776&lang=pug in ./src/layouts/blank.vue

这是完整的错误

这是空白的.vue 文件

<template lang="pug">
  nuxt
</template>

这是我的 nuxt.config.js

import webpack from 'webpack'
import CompressionPlugin from 'compression-webpack-plugin'
import { config } from 'dotenv'

config()

const siteUrl = {
  'development': 'http://localhost:9001'
}

const modules = [
  '@nuxtjs/axios',
  '@nuxtjs/auth',
  '@nuxtjs/sitemap',
  '@nuxtjs/font-awesome',
  '@nuxtjs/browserconfig'
]

// Add any dev-only nuxt modules here
if (process.env.NODE_ENV === 'development') {
  modules.push('@nuxtjs/webpackmonitor')
}

export default {
  debug: true,
  /*
  ** Headers of the page
  */
  head: {
    title: '',
    htmlAttrs: {
      lang: 'en'
    },
    __dangerouslyDisableSanitizersByTagID: {
      act: ['innerHTML'],
      ieFix: ['innerHTML']
    }
  },
  performance: {
    prefetch: true
  },
  loading: false,
  modules,
  browserconfig: {
    TileColor: '#f16365',
    square150x150logo: {
      '@': {
        src: 'icon.png'
      }
    }
  },
  sitemap: {
    routes: []
  },
  vendor: [],
  publicRuntimeConfig: {
    environment: process.env.NODE_ENV,
    MAPS_KEY: process.env.MAPS_KEY
  },
  /*
  ** Global CSS
  */
  css: [
    '~/assets/css/tooltips.css',
    '~/assets/css/overrides.css',
    // scss
    '~/assets/scss/main.scss'
  ],
  auth: {
    plugins: ['~/plugins/auth.js'],
    redirect: {
      login: '/auth/login',
      logout: '/',
      home: '/home',
      callback: false,
      user: '/'
    },
    resetOnError: true,
    fullPathRedirect: true,
    defaultStrategy: 'local',
    strategies: {
      local: {
        endpoints: {
          login: { url: '/api/v2/auth/token', method: 'post', propertyName: 'access_token' },
          logout: { url: '/api/v2/auth/revoke', method: 'post' },
          user: { url: '/api/v2/user', method: 'get', propertyName: 'data' }
        }
      }
    }
  },
  plugins: [
    '~/plugins/stripe',
    '~/plugins/social-sharing',
    '~/plugins/vendor',
    '~/plugins/mobile-layout',
    '~/plugins/validate'
  ],
  router: {
    linkActiveClass: 'is-active',
    middleware: ['auth']
  },
  srcDir: 'src/',
  axios: {
    baseURL: siteUrl['development'],
    proxy: true,
    headers: {
      'Accept': 'application/json',
      'Content-Type': 'application/json'
    }
  },
  build: {
    babel: {
      presets: ['@babel/preset-env'],
      plugins: [
        '@babel/plugin-proposal-function-bind',
        '@babel/plugin-transform-runtime',
        'lodash'
      ]
    },
    analyze: false,
    vendor: [
      'babel-polyfill',
      'axios',
      'jquery',
      'bootstrap',
      'vue-notification'
    ],
    plugins: [
      new webpack.ProvidePlugin({
        $: 'jquery',
        jQuery: 'jquery',
        'window.jQuery': 'jquery'
      }),
      new webpack.IgnorePlugin(/^\.\/locale$/, /moment$/),
      new CompressionPlugin({
        asset: '[path].gz[query]',
        algorithm: 'gzip',
        test: /\.js$|\.css$|\.html$/,
        threshold: 10240,
        minRatio: 0
      })
    ]
  }
}

我是否遗漏了 v2 迁移的配置?我遵循了这个指南:https://github.com/nuxt/nuxt/releases/tag/v2.0.0

或者有没有新的方式来加载vue模板?发布 nuxt v1 吗?任何帮助表示赞赏。谢谢!

javascript vue.js webpack nuxt.js nuxtjs2
1个回答
0
投票

在此线程中找到修复:https://github.com/nuxt/nuxt/pull/4824

我只是跑了

yarn add -D pug-plain-loader

然后在 nuxt.config.js 中扩展我的 webpack 配置

    extend (config, { isDev, isClient }) {
      // Add pug loader
      config.module.rules.push({
        test: /\.pug$/,
        loader: 'pug-plain-loader'
      })
    },
© www.soinside.com 2019 - 2024. All rights reserved.