小编Kel*_*lly的帖子

SyntaxError: 当运行时为自动时,无法设置 pragma 和 pragmaFrag

我正在将一个项目从 Next 9 迁移到 Next 11,默认情况下使用 webpack5。修复加载器问题(如 next.config.js 文件中所示)后,出现以下错误:

SyntaxError: pragma and pragmaFrag cannot be set when runtime is automatic

我尝试使用这些解决方案进行调试,但仍然触发相同的错误。

我的代码:

next.config.js

const withImages = require("next-images");
const { PHASE_DEVELOPMENT_SERVER } = require("next/constants");
const withYaml = require("next-plugin-yaml");
const babel = require('babel-plugin-import-glob-array');

module.exports = (phase) =>
  withYaml(
    withImages(
({
        target: "serverless",
        env: {
          isDev: phase === PHASE_DEVELOPMENT_SERVER,
        },
        webpack5: true,
        webpack: (config, options) => {
          config.module.rules.push({
            test: /\.mdx/,
            use: [
              options.defaultLoaders.babel,
              {
                loader: '@mdx-js/loader',
                options: babel.options,
              },
            ],
          }); …
Run Code Online (Sandbox Code Playgroud)

pragma emotion reactjs babeljs next.js

5
推荐指数
0
解决办法
2244
查看次数

标签 统计

babeljs ×1

emotion ×1

next.js ×1

pragma ×1

reactjs ×1