webpack 在我更新到v2.15后,NuxtJs开发构建中断

zte4gxcn  于 2023-11-19  发布在  Webpack
关注(0)|答案(1)|浏览(129)

我最近更新了我的旧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

字符串
这是完整的错误x1c 0d1x
这是空白的.vue文件

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


这是我的nuxt.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?任何帮助是感激。谢谢!

ru9i0ody

ru9i0ody1#

在这个线程中找到了修复:https://github.com/nuxt/nuxt/pull/4824
我只是运行yarn add -D pug-plain-loader
然后在nuxt.js.js中扩展我的webpack配置

extend (config, { isDev, isClient }) {
      // Add pug loader
      config.module.rules.push({
        test: /\.pug$/,
        loader: 'pug-plain-loader'
      })
    },

字符串

相关问题