0

Very new to webpack, trying to solve an issue I'm having with Nuxt and Netlify CMS.

Inside static/admin/index.html I load this file static/cms/index.js:

// This global flag enables manual initialization.
window.CMS_MANUAL_INIT = true
// Usage with import from npm package
import CMS, { init } from '../../node_modules/netlify-cms-app'
import pages from './pages'

/**
 * Optionally pass in a complete config object and set a flag
 *  (`load_config_file: false`) to ignore the `config.yml`.
 *
 * For example, the code below contains a complete config. The
 * `config.yml` will be ignored when setting `load_config_file` to false.
 * It is not required if the `config.yml` file is missing to set
 * `load_config_file`, but will improve performance and avoid a load error.
 */
init({
  config: {
    backend: {
      name: 'git-gateway',
      branch: 'master',
    },
    load_config_file: false,
    media_folder: 'static/images/uploads',
    public_folder: '/images/uploads',
    publish_mode: 'editorial_workflow',
    collections: [
      pages
    ],
  },
})

// The registry works as expected, and can be used before or after init.
// CMS.registerPreviewTemplate(...);

I think all I need to do is bundle that file so it includes the imported scripts, and have it output in the same location at the end.

There error I'm getting:

Failed to load module script: Expected a JavaScript module script but the server responded with a MIME type of "text/html". Strict MIME type checking is enforced for module scripts per HTML spec.
pages:1 Failed to load module script: Expected a JavaScript module script but the server responded with a MIME type of "text/html". Strict MIME type checking is enforced for module scripts per HTML spec.

Inside nuxt.config.js:

build: {
    extend(config, { isDev, isClient }) {
      // me attempting to fix it
      console.log(config.module.rules[1]);
      config.module.rules.push({
        test: /\.(js)?$/,
      })
    }
  }
}
Jarrod
  • 89
  • 1
  • 7
  • Are those files even supposed to be in `static` in first place? I mean, do you allow anybody to reach them for some reason? – kissu Aug 22 '21 at 21:05
  • @kissu yes. Their official documentation: https://www.netlifycms.org/docs/nuxt/ – Jarrod Aug 22 '21 at 21:08

0 Answers0