NUXT - Не удалось загрузить ресурс: сервер ответил со статусом 404 - PullRequest
0 голосов
/ 10 февраля 2019

Я борюсь с развертыванием приложения nuxt create-app.

Фактически, когда я запускаю $ npm run generate, он создает папку dist с неверным путем для папки _nuxt/.

На самом деле правильный относительный путь к файлам .html должен быть _nuxt/test.js, а не /_nuxt/test.js (без первого "/"), поскольку он будет искать файлы в корневом каталоге.

Я уже искал часы и часы, но я не могу найти правильное решение.Я нашел это Ошибки при публикации моего сайта nuxtjs в режиме SSR , но, к сожалению, я не понимаю, как это реализовать, что такое ngix?какой файл я должен изменить?Я не знаю

Здесь, под моим nuxt.config.js

const pkg = require('./package')

module.exports = {
  mode: 'universal',

  /*
  ** Headers of the page
  */
  head: {
    title: pkg.name,
    meta: [
      { charset: 'utf-8' },
      { name: 'viewport', content: 'width=device-width, initial-scale=1' },
      { hid: 'description', name: 'description', content: pkg.description },
      { hid: 'keywords', name: 'keywords', content: 'pellet, pellets, madrid, cuenca, segovia, toledo, guadalajara' }
    ],
    link: [
      { rel: 'icon', type: 'image/x-icon', href: '/favicon.ico' },
      { rel: 'stylesheet', href: 'https://fonts.googleapis.com/css?family=Merriweather|Open+Sans'},
      { rel: 'stylesheet', href: 'assets/fonts/fontawesome/css/all.css'}
    ]
  },

  /*
  ** Customize the progress-bar color
  */
  loading: { color: '#fff' },

  /*
  ** Global CSS
  */
  css: [
    // SCSS file in the project
    '@/assets/css/main.scss'
  ],

  /*
  ** Plugins to load before mounting the App
  */
  plugins: [
    '@/plugins/vee-validate'
  ],

  /*
  ** Nuxt.js modules
  */
  modules: [
    // Doc: https://axios.nuxtjs.org/usage
    '@nuxtjs/axios',
    // Doc: https://bootstrap-vue.js.org/docs/
    'bootstrap-vue/nuxt'
  ],
  /*
  ** Axios module configuration
  */
  axios: {
    // See https://github.com/nuxt-community/axios-module#options
  },

  /*
  ** Build configuration
  */
  build: {

    /*
    ** You can extend webpack config here
    */
    extend(config, ctx) {
      // Run ESLint on save
      if (ctx.isDev && ctx.isClient) {
        config.module.rules.push({
          enforce: 'pre',
          test: /\.(js|vue)$/,
          loader: 'eslint-loader',
          exclude: /(node_modules)/,
          options : {
            fix : true
          }
        })
      }
    },

    /*
    ** POST CSS 
    */
    postcss: {
      // Add plugin names as key and arguments as value
      // Install them before as dependencies with npm or yarn
      //postcss-loader autoprefixer
      plugins: {
       // Disable a plugin by passing false as value 
       // 'postcss-url': false,
       // 'postcss-nested': false,
       // 'postcss-responsive-type': false,
        'postcss-hexrgba': {}
      },
      preset: {
        // Change the postcss-preset-env settings
        autoprefixer: {
          grid: true
        }
      }
    }

  }
}

Пожалуйста, помогите мне окончательно решить этот кошмар.Большое спасибо,

1 Ответ

0 голосов
/ 10 февраля 2019

вы должны использовать ниже конфигурации

  const pkg = require('./package')

    module.exports = {
      mode: 'spa',
    router: {
    base: '/',// for base path
  },
      /*
      ** Headers of the page
      */
      head: {
        title: pkg.name,
        meta: [
          { charset: 'utf-8' },
          { name: 'viewport', content: 'width=device-width, initial-scale=1' },
          { hid: 'description', name: 'description', content: pkg.description },
          { hid: 'keywords', name: 'keywords', content: 'pellet, pellets, madrid, cuenca, segovia, toledo, guadalajara' }
        ],
        link: [
          { rel: 'icon', type: 'image/x-icon', href: '/favicon.ico' },
          { rel: 'stylesheet', href: 'https://fonts.googleapis.com/css?family=Merriweather|Open+Sans'},
          { rel: 'stylesheet', href: 'assets/fonts/fontawesome/css/all.css'}
        ]
      },

      /*
      ** Customize the progress-bar color
      */
      loading: { color: '#fff' },

      /*
      ** Global CSS
      */
      css: [
        // SCSS file in the project
        '@/assets/css/main.scss'
      ],

      /*
      ** Plugins to load before mounting the App
      */
      plugins: [
        '@/plugins/vee-validate'
      ],

      /*
      ** Nuxt.js modules
      */
      modules: [
        // Doc: https://axios.nuxtjs.org/usage
        '@nuxtjs/axios',
        // Doc: https://bootstrap-vue.js.org/docs/
        'bootstrap-vue/nuxt'
      ],
      /*
      ** Axios module configuration
      */
      axios: {
        // See https://github.com/nuxt-community/axios-module#options
      },

      /*
      ** Build configuration
      */
      build: {
    publicPath: 'public/',
        /*
        ** You can extend webpack config here
        */
        extend(config, ctx) {
          // Run ESLint on save
          if (ctx.isDev && ctx.isClient) {
            config.module.rules.push({
              enforce: 'pre',
              test: /\.(js|vue)$/,
              loader: 'eslint-loader',
              exclude: /(node_modules)/,
              options : {
                fix : true
              }
            })
          }
        },

        /*
        ** POST CSS 
        */
        postcss: {
          // Add plugin names as key and arguments as value
          // Install them before as dependencies with npm or yarn
          //postcss-loader autoprefixer
          plugins: {
           // Disable a plugin by passing false as value 
           // 'postcss-url': false,
           // 'postcss-nested': false,
           // 'postcss-responsive-type': false,
            'postcss-hexrgba': {}
          },
          preset: {
            // Change the postcss-preset-env settings
            autoprefixer: {
              grid: true
            }
          }
        }

      }
    }
...