代码之家  ›  专栏  ›  技术社区  ›  Jeff M

Gatsby进口Babel Polyfill

  •  1
  • Jeff M  · 技术社区  · 6 年前

    我遇到的根本问题是IE11失败了 Object doesn't support property or method 'find' . 似乎我需要进口巴别多菲勒,但我找不到合适的地方做进口。

    • 我尝试在layout index.js中导入,但是当我这样做时 gatsby build 失败 Module build failed: Error: only one instance of babel-polyfill is allowed .
    • 我试过在gatsby-browser.js和gatsby-node.js中进行需求构建,但是当我这样做时,IE中的错误仍然会出现,就像从未加载babel polyfill一样。
    • 我试过在gatsby-config.js中要求,但是当我这样做的时候 盖茨比建筑 又失败了。

    我该怎么办?

    2 回复  |  直到 6 年前
        1
  •  0
  •   Jeff M    6 年前

    // gatsby-node.js
    
    exports.modifyWebpackConfig = ({ config, stage }) => {
        if (stage === "build-javascript") {
            config._config.entry.app = ["babel-polyfill", config.resolve().entry.app];
        }
    
        return config;
    };
    

    _config

    exports.modifyWebpackConfig = ({ config, stage }) => {
        if (stage === "build-javascript") {
            config.merge({
                entry: {app: ["babel-polyfill", config.resolve().entry.app]}
            });
        }
    
        return config;
    };
    

    entry.app