Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/typescript/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/webpack/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Typescript CssSyntaxError:生产环境中缺少分号_Typescript_Webpack_Node Modules - Fatal编程技术网

Typescript CssSyntaxError:生产环境中缺少分号

Typescript CssSyntaxError:生产环境中缺少分号,typescript,webpack,node-modules,Typescript,Webpack,Node Modules,我试图在我们的项目上运行npm构建,即“webpack--mode=production--config./config/webpack.config.prod.js” 我在我的tsx文件中添加了引导文件,如下所示 import bs from "../../../../../../node_modules/bootstrap/scss/bootstrap.scss"; 但我正在解决这个问题 CssSyntaxError: Missed semicolon at Input

我试图在我们的项目上运行npm构建,即“webpack--mode=production--config./config/webpack.config.prod.js”

我在我的tsx文件中添加了引导文件,如下所示

import bs from "../../../../../../node_modules/bootstrap/scss/bootstrap.scss";
但我正在解决这个问题

CssSyntaxError: Missed semicolon
at Input.error (/Users/m.g2/Desktop/WebPanel/WebpanelClient/node_modules/postcss/lib/input.js:128:16)
at Parser.checkMissedSemicolon (/Users/m.g2/Desktop/WebPanel/WebpanelClient/node_modules/postcss/lib/parser.js:601:22)
at Parser.decl (/Users/m.g2/Desktop/WebPanel/WebpanelClient/node_modules/postcss/lib/parser.js:284:46)
at Parser.other (/Users/m.g2/Desktop/WebPanel/WebpanelClient/node_modules/postcss/lib/parser.js:131:18)
at Parser.parse (/Users/m.g2/Desktop/WebPanel/WebpanelClient/node_modules/postcss/lib/parser.js:75:16)
at parse (/Users/m.g2/Desktop/WebPanel/WebpanelClient/node_modules/postcss/lib/parse.js:17:12)
at new LazyResult (/Users/m.g2/Desktop/WebPanel/WebpanelClient/node_modules/postcss/lib/lazy-result.js:64:16)
at Processor.<anonymous> (/Users/m.g2/Desktop/WebPanel/WebpanelClient/node_modules/postcss/lib/processor.js:142:12)
at Processor.process (/Users/m.g2/Desktop/WebPanel/WebpanelClient/node_modules/postcss/lib/processor.js:121:23)
at Function.creator.process (/Users/m.g2/Desktop/WebPanel/WebpanelClient/node_modules/postcss/lib/postcss.js:148:43)
at OptimizeCssAssetsWebpackPlugin.processCss (/Users/m.g2/Desktop/WebPanel/WebpanelClient/web/Web/node_modules/optimize-css-assets-webpack-plugin/src/index.js:73:21)
at Object.processor (/Users/m.g2/Desktop/WebPanel/WebpanelClient/web/Web/node_modules/optimize-css-assets-webpack-plugin/src/index.js:13:18)
at each (/Users/m.g2/Desktop/WebPanel/WebpanelClient/node_modules/last-call-webpack-plugin/src/index.js:150:10)
at arrayEach (/Users/m.g2/Desktop/WebPanel/WebpanelClient/node_modules/lodash/_arrayEach.js:15:9)
at forEach (/Users/m.g2/Desktop/WebPanel/WebpanelClient/node_modules/lodash/forEach.js:38:10)
at OptimizeCssAssetsWebpackPlugin.process (/Users/m.g2/Desktop/WebPanel/WebpanelClient/node_modules/last-call-webpack-plugin/src/index.js:147:5)
at compilation.hooks.optimizeChunkAssets.tapPromise.chunks (/Users/m.g2/Desktop/WebPanel/WebpanelClient/node_modules/last-call-webpack-plugin/src/index.js:178:28)
at AsyncSeriesHook.eval [as callAsync] (eval at create (/Users/m.g2/Desktop/WebPanel/WebpanelClient/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:25:17)
at AsyncSeriesHook.lazyCompileHook (/Users/m.g2/Desktop/WebPanel/WebpanelClient/node_modules/tapable/lib/Hook.js:154:20)
at hooks.additionalAssets.callAsync.err (/Users/m.g2/Desktop/WebPanel/WebpanelClient/node_modules/webpack/lib/Compilation.js:1381:36)
at _promise0.then._result0 (eval at create (/Users/m.g2/Desktop/WebPanel/WebpanelClient/node_modules/tapable/lib/HookCodeFactory.js:33:10), 

<anonymous>:18:1)
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
error Command failed.
Exit code: 1
如果我从cssConfig.js文件中删除
MiniCssExtractPlugin.loader
,那么它工作正常

webpack.config.common.js

const path = require("path");
const globalSass = require("./globalSass");

module.exports = {
    sass: env => {
        if (env === "production") {
            const MiniCssExtractPlugin = require("mini-css-extract-plugin");

        return [
            MiniCssExtractPlugin.loader,
            "css-loader?localIdentName=[hash:base64:20]&modules&importLoaders=3",
            {
                loader: "postcss-loader",
                options: {
                    sourceMap: false,
                    config: {
                        path: path.resolve(__dirname, "postcss.config.js"),
                    },
                },
            },
            "sass-loader",
            { ...globalSass({ sourceMap: false }) },
        ];
    }
    return [
        "style-loader",
        "css-loader?localIdentName=[path][name]__[local]&modules&importLoaders=3&sourceMap",
        {
            loader: "postcss-loader",
            options: {
                sourceMap: true,
                config: {
                    path: path.resolve(__dirname, "postcss.config.js"),
                },
            },
        },
        "sass-loader?sourceMap",
        { ...globalSass({ sourceMap: true }) },
    ];
},
css: env => {
    if (env === "production") {
        const MiniCssExtractPlugin = require("mini-css-extract-plugin");

        return [
            MiniCssExtractPlugin.loader,
            "css-loader?localIdentName=[hash:base64:20]&modules&importLoaders=1",
            {
                loader: "postcss-loader",
                options: {
                    sourceMap: false,
                    config: {
                        path: path.resolve(__dirname, "postcss.config.js"),
                    },
                },
            },
        ];
    }
    return [
        "style-loader",
        "css-loader?localIdentName=[path][name]__[local]&modules&importLoaders=1&sourceMap",
        {
            loader: "postcss-loader",
            options: {
                sourceMap: true,
                config: {
                    path: path.resolve(__dirname, "postcss.config.js"),
                },
            },
        },
    ];
},
vendorCss: () => {
    return ["style-loader", "css-loader"];
},
};
const webpack = require("webpack");
const path = require("path");
const paths = require("./paths");
const WebpackBar = require("webpackbar");
const BundleAnalyzerPlugin = require("webpack-bundle-analyzer").BundleAnalyzerPlugin;

const HtmlWebpackPlugin = require("html-webpack-plugin");
const FaviconsWebpackPlugin = require("favicons-webpack-plugin");
const CopyWebpackPlugin = require("copy-webpack-plugin");
const ForkTsCheckerPlugin = require("fork-ts-checker-webpack-plugin");
const TsconfigPathsPlugin = require("tsconfig-paths-webpack-plugin");

const deployDir = process.env.DEPLOY_DIR || path.resolve(__dirname, "..", "..", "..", "deploy", "Apps", "Web");
const cssConfig = require("./cssConfig");

console.log("DEPLOY DIRECTORY", path.resolve(deployDir));

/**
 * Polyfills required for node_modules (by ie 11 target at the time of writing)
 */
const polyfills = [
    "core-js/modules/es.array.fill",
    "core-js/modules/es.array.find",
    "core-js/modules/es.array.iterator",
    "core-js/modules/es.promise",
    "core-js/modules/es.number.is-integer",
    "core-js/modules/es.object.entries",
    "core-js/modules/es.object.values",
    "core-js/modules/es.set",
    "core-js/modules/es.symbol",
    "core-js/modules/web.url",
    "core-js/modules/web.url.to-json",
    "core-js/modules/web.url-search-params",
];

module.exports = (env = {}, argv = {}) => {
    const isProd = (argv.mode || "").toLocaleLowerCase() !== "development";

const urlLoaderOptions = {
    loader: "url-loader",
    options: {
        limit: 10000,
        name: !isProd ? "images/[path][name].[ext]" : "images/[name]-[contenthash].[ext]",
        esModule: false,
    },
};
/**
 * This is for eslint. If you're running eslint in a different node version
 * than this repository uses (10), it might have issues loading some modules
 * like `sharp`. This env is set by eslintrc
 */
const isEditor = env.editor === "true";

return {
    entry: [...polyfills, path.join(paths.ts, "index.tsx")],

    plugins: [
        !argv.storybook &&
            new HtmlWebpackPlugin({
                template: path.join(paths.appRoot, "index.html"),
            }),
        new webpack.EnvironmentPlugin({
            APP_VERSION: "0.0.0-dev",
            AUTH_ENDPOINT: "",
        }),
        !argv.storybook &&
            new FaviconsWebpackPlugin({
                logo: path.join(paths.images, "logo-small.png"),
                title: "Shell Fleet Assistant",
                prefix: "icons/",
            }),
        new CopyWebpackPlugin([
            {
                from: paths.public,
            },
            {
                from: paths.images,
                to: "images/",
            },
            {
                from: "janrain.html",
                to: "internal/janrain/index.html",
            },
        ]),
        new webpack.IgnorePlugin(/^\.\/locale$/, /moment$/),
        new ForkTsCheckerPlugin({
            async: !isProd,
            typescript: {
                configFile: argv.storybook ? paths.tsConfig : paths.tsConfigNoStorybook,
                mode: "write-references",
                profile: !!argv.profile,
            },
            eslint: {
                enabled: true,
                files: [paths.ts, paths.commonRoot],
            },
        }),
        new webpack.ProvidePlugin({
            OptiTruck: ["OptiTruck", "globals"],
            Messaging: ["Messaging", "globals"],
            $: "jquery",
        }),
        new WebpackBar({
            profile: !!argv.profile,
        }),
        !!argv.profile && new BundleAnalyzerPlugin(),
    ].filter(Boolean),

    output: {
        path: path.resolve(deployDir),
        filename: isProd ? "[name]-[contenthash].js" : "[name].js",
        publicPath: "/",
        pathinfo: false,
    },

    resolve: {
        extensions: [".ts", ".tsx", ".js"],
        alias: {
            "push-notifications": paths.pushNotifications("web"),
            "app-router": paths.appRouter("web"),
            OptiTruck: path.resolve(paths.ts, "Contracts/OptiTruckClient"),
            Messaging: path.resolve(paths.ts, "Contracts/MessagingClient"),
            // IE 11 compat; react-spring is ES6 by default, `.cjs` version is ES5
            "react-spring$": require.resolve("react-spring/web.cjs.js"),
            "react-hook-form$": require.resolve("react-hook-form/dist/react-hook-form.ie11"),
        },
        plugins: [new TsconfigPathsPlugin({ configFile: paths.tsConfig })],
    },

    optimization: {
        splitChunks: {
            chunks: "all",
        },
    },

    module: {
        rules: [
            {
                test: /\.[jt]sx?$/,
                loader: "babel-loader",
                include: [paths.ts, paths.commonRoot],
                exclude: /node_modules/,
                options: {
                    babelrc: false,
                    sourceMaps: true,
                    cacheDirectory: !isProd,
                    presets: [
                        [
                            "@babel/env",
                            {
                                useBuiltIns: "usage",
                                corejs: 3,
                            },
                        ],
                        "@babel/react",
                        "@babel/typescript",
                    ],
                    plugins: [
                        "emotion",
                        "@babel/plugin-syntax-dynamic-import",
                        ["@babel/plugin-proposal-class-properties", { loose: false }],
                        "dev-expression",
                        "const-enum",
                    ],
                },
            },
            {
                test: /\.css$/,
                use: cssConfig.vendorCss(),
                include: /node_modules/,
            },
            {
                test: /\.css$/,
                use: cssConfig.css(isProd ? "production" : "development"),
                exclude: /node_modules/,
            },
            {
                test: /\.(sass|scss)$/,
                use: cssConfig.sass(isProd ? "production" : "development"),
            },
            {
                test: /\.(ttf|eot)(\?[\s\S]+)?$/,
                loader: "file-loader",
                options: {
                    name: "fonts/[name].[ext]",
                },
            },
            {
                test: /\.(png|svg|gif|jpe?g)$/,
                oneOf: [
                    {
                        test: /\.(png|jpe?g)$/,
                        resourceQuery: /lqip/,
                        use: [
                            {
                                loader: "lqip-loader",
                                options: {
                                    base64: true,
                                },
                            },
                        ],
                    },
                    {
                        test: /\.(png|jpe?g)$/,
                        resourceQuery: /webp/,
                        use: [
                            {
                                loader: "responsive-loader",
                                options: {
                                    adapter: !isEditor && require("responsive-loader/sharp"),
                                },
                            },
                            {
                                loader: "img-loader",
                                options: {
                                    plugins: [
                                        require("imagemin-mozjpeg")(),
                                        require("imagemin-svgo")(),
                                        require("imagemin-webp")(),
                                        require("imagemin-optipng")(),
                                    ],
                                },
                            },
                            {
                                loader: "webp-loader",
                            },
                        ],
                    },
                    {
                        test: /\.(png|jpe?g)$/,
                        resourceQuery: /responsive/,
                        use: [
                            {
                                loader: "responsive-loader",
                                options: {
                                    adapter: !isEditor && require("responsive-loader/sharp"),
                                },
                            },
                            {
                                loader: "img-loader",
                                options: {
                                    plugins: [
                                        require("imagemin-mozjpeg")(),
                                        require("imagemin-svgo")(),
                                        require("imagemin-webp")(),
                                        require("imagemin-optipng")(),
                                    ],
                                },
                            },
                        ],
                    },
                    {
                        test: /\.svg$/,
                        resourceQuery: /svgr/,
                        use: ["@svgr/webpack", urlLoaderOptions],
                    },
                    {
                        use: [urlLoaderOptions],
                    },
                ],
            },
        ],
    },
};
};
const webpack = require("webpack");
const paths = require("./paths");
const merge = require("webpack-merge");
const path = require("path");

const HtmlWebpackIncludeAssetsPlugin = require("html-webpack-include-assets-plugin");
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
const OptimizeCSSAssetsPlugin = require("optimize-css-assets-webpack-plugin");
const RobotstxtPlugin = require("robotstxt-webpack-plugin");
const WebpackPwaManifest = require("webpack-pwa-manifest");
const CircularDependencyPlugin = require("circular-dependency-plugin");

const CommonConfig = require("./webpack.config.common.js");

const CspHtmlWebpackPlugin = require("csp-html-webpack-plugin");
const csp = require("./csp");

module.exports = (env, argv) =>
    merge(CommonConfig(env, argv), {
        devtool: "source-map",
        plugins: [
            new CspHtmlWebpackPlugin(
                {
                    "script-src": ["'self'", "'unsafe-inline'", ...csp.allowedScriptSrc],
                    "style-src": ["'self'", "'unsafe-inline'", ...csp.allowedStylesSrc],
                },
                {
                    nonceEnabled: {
                        "script-src": false,
                        "style-src": false,
                    },
                    hashEnabled: {
                        // disable hashing as 'unsafe-inline' is present
                        "script-src": false,
                    },
                },
            ),
            new webpack.EnvironmentPlugin({
                PLATFORM: "web",
            }),
            new WebpackPwaManifest({
                filename: "manifest.webmanifest",
                name: "Shell Fleet Assistant",
                short_name: "FleetAssistant",
                start_url: ".",
                display: "standalone",
                orientation: "portrait",
            }),
            new HtmlWebpackIncludeAssetsPlugin({
                assets: ["config.js"],
                append: false,
            }),
            new RobotstxtPlugin({
                policy: [
                    {
                        userAgent: "*",
                        disallow: "/",
                    },
                ],
            }),
            new MiniCssExtractPlugin({
                filename: "[name]-[contenthash].css",
            }),
            new OptimizeCSSAssetsPlugin({}),
            new CircularDependencyPlugin({
                // exclude detection of files based on a RegExp
                exclude: /node_modules/,
                // add errors to webpack instead of warnings
                failOnError: true,
                // set the current working directory for displaying module paths
                cwd: process.cwd(),
            }),
        ],
    resolve: {
        alias: {
            config: paths.config("production"),
        },
    },

    stats: {
        children: false,
    },
});
webpack.config.prod.js

const path = require("path");
const globalSass = require("./globalSass");

module.exports = {
    sass: env => {
        if (env === "production") {
            const MiniCssExtractPlugin = require("mini-css-extract-plugin");

        return [
            MiniCssExtractPlugin.loader,
            "css-loader?localIdentName=[hash:base64:20]&modules&importLoaders=3",
            {
                loader: "postcss-loader",
                options: {
                    sourceMap: false,
                    config: {
                        path: path.resolve(__dirname, "postcss.config.js"),
                    },
                },
            },
            "sass-loader",
            { ...globalSass({ sourceMap: false }) },
        ];
    }
    return [
        "style-loader",
        "css-loader?localIdentName=[path][name]__[local]&modules&importLoaders=3&sourceMap",
        {
            loader: "postcss-loader",
            options: {
                sourceMap: true,
                config: {
                    path: path.resolve(__dirname, "postcss.config.js"),
                },
            },
        },
        "sass-loader?sourceMap",
        { ...globalSass({ sourceMap: true }) },
    ];
},
css: env => {
    if (env === "production") {
        const MiniCssExtractPlugin = require("mini-css-extract-plugin");

        return [
            MiniCssExtractPlugin.loader,
            "css-loader?localIdentName=[hash:base64:20]&modules&importLoaders=1",
            {
                loader: "postcss-loader",
                options: {
                    sourceMap: false,
                    config: {
                        path: path.resolve(__dirname, "postcss.config.js"),
                    },
                },
            },
        ];
    }
    return [
        "style-loader",
        "css-loader?localIdentName=[path][name]__[local]&modules&importLoaders=1&sourceMap",
        {
            loader: "postcss-loader",
            options: {
                sourceMap: true,
                config: {
                    path: path.resolve(__dirname, "postcss.config.js"),
                },
            },
        },
    ];
},
vendorCss: () => {
    return ["style-loader", "css-loader"];
},
};
const webpack = require("webpack");
const path = require("path");
const paths = require("./paths");
const WebpackBar = require("webpackbar");
const BundleAnalyzerPlugin = require("webpack-bundle-analyzer").BundleAnalyzerPlugin;

const HtmlWebpackPlugin = require("html-webpack-plugin");
const FaviconsWebpackPlugin = require("favicons-webpack-plugin");
const CopyWebpackPlugin = require("copy-webpack-plugin");
const ForkTsCheckerPlugin = require("fork-ts-checker-webpack-plugin");
const TsconfigPathsPlugin = require("tsconfig-paths-webpack-plugin");

const deployDir = process.env.DEPLOY_DIR || path.resolve(__dirname, "..", "..", "..", "deploy", "Apps", "Web");
const cssConfig = require("./cssConfig");

console.log("DEPLOY DIRECTORY", path.resolve(deployDir));

/**
 * Polyfills required for node_modules (by ie 11 target at the time of writing)
 */
const polyfills = [
    "core-js/modules/es.array.fill",
    "core-js/modules/es.array.find",
    "core-js/modules/es.array.iterator",
    "core-js/modules/es.promise",
    "core-js/modules/es.number.is-integer",
    "core-js/modules/es.object.entries",
    "core-js/modules/es.object.values",
    "core-js/modules/es.set",
    "core-js/modules/es.symbol",
    "core-js/modules/web.url",
    "core-js/modules/web.url.to-json",
    "core-js/modules/web.url-search-params",
];

module.exports = (env = {}, argv = {}) => {
    const isProd = (argv.mode || "").toLocaleLowerCase() !== "development";

const urlLoaderOptions = {
    loader: "url-loader",
    options: {
        limit: 10000,
        name: !isProd ? "images/[path][name].[ext]" : "images/[name]-[contenthash].[ext]",
        esModule: false,
    },
};
/**
 * This is for eslint. If you're running eslint in a different node version
 * than this repository uses (10), it might have issues loading some modules
 * like `sharp`. This env is set by eslintrc
 */
const isEditor = env.editor === "true";

return {
    entry: [...polyfills, path.join(paths.ts, "index.tsx")],

    plugins: [
        !argv.storybook &&
            new HtmlWebpackPlugin({
                template: path.join(paths.appRoot, "index.html"),
            }),
        new webpack.EnvironmentPlugin({
            APP_VERSION: "0.0.0-dev",
            AUTH_ENDPOINT: "",
        }),
        !argv.storybook &&
            new FaviconsWebpackPlugin({
                logo: path.join(paths.images, "logo-small.png"),
                title: "Shell Fleet Assistant",
                prefix: "icons/",
            }),
        new CopyWebpackPlugin([
            {
                from: paths.public,
            },
            {
                from: paths.images,
                to: "images/",
            },
            {
                from: "janrain.html",
                to: "internal/janrain/index.html",
            },
        ]),
        new webpack.IgnorePlugin(/^\.\/locale$/, /moment$/),
        new ForkTsCheckerPlugin({
            async: !isProd,
            typescript: {
                configFile: argv.storybook ? paths.tsConfig : paths.tsConfigNoStorybook,
                mode: "write-references",
                profile: !!argv.profile,
            },
            eslint: {
                enabled: true,
                files: [paths.ts, paths.commonRoot],
            },
        }),
        new webpack.ProvidePlugin({
            OptiTruck: ["OptiTruck", "globals"],
            Messaging: ["Messaging", "globals"],
            $: "jquery",
        }),
        new WebpackBar({
            profile: !!argv.profile,
        }),
        !!argv.profile && new BundleAnalyzerPlugin(),
    ].filter(Boolean),

    output: {
        path: path.resolve(deployDir),
        filename: isProd ? "[name]-[contenthash].js" : "[name].js",
        publicPath: "/",
        pathinfo: false,
    },

    resolve: {
        extensions: [".ts", ".tsx", ".js"],
        alias: {
            "push-notifications": paths.pushNotifications("web"),
            "app-router": paths.appRouter("web"),
            OptiTruck: path.resolve(paths.ts, "Contracts/OptiTruckClient"),
            Messaging: path.resolve(paths.ts, "Contracts/MessagingClient"),
            // IE 11 compat; react-spring is ES6 by default, `.cjs` version is ES5
            "react-spring$": require.resolve("react-spring/web.cjs.js"),
            "react-hook-form$": require.resolve("react-hook-form/dist/react-hook-form.ie11"),
        },
        plugins: [new TsconfigPathsPlugin({ configFile: paths.tsConfig })],
    },

    optimization: {
        splitChunks: {
            chunks: "all",
        },
    },

    module: {
        rules: [
            {
                test: /\.[jt]sx?$/,
                loader: "babel-loader",
                include: [paths.ts, paths.commonRoot],
                exclude: /node_modules/,
                options: {
                    babelrc: false,
                    sourceMaps: true,
                    cacheDirectory: !isProd,
                    presets: [
                        [
                            "@babel/env",
                            {
                                useBuiltIns: "usage",
                                corejs: 3,
                            },
                        ],
                        "@babel/react",
                        "@babel/typescript",
                    ],
                    plugins: [
                        "emotion",
                        "@babel/plugin-syntax-dynamic-import",
                        ["@babel/plugin-proposal-class-properties", { loose: false }],
                        "dev-expression",
                        "const-enum",
                    ],
                },
            },
            {
                test: /\.css$/,
                use: cssConfig.vendorCss(),
                include: /node_modules/,
            },
            {
                test: /\.css$/,
                use: cssConfig.css(isProd ? "production" : "development"),
                exclude: /node_modules/,
            },
            {
                test: /\.(sass|scss)$/,
                use: cssConfig.sass(isProd ? "production" : "development"),
            },
            {
                test: /\.(ttf|eot)(\?[\s\S]+)?$/,
                loader: "file-loader",
                options: {
                    name: "fonts/[name].[ext]",
                },
            },
            {
                test: /\.(png|svg|gif|jpe?g)$/,
                oneOf: [
                    {
                        test: /\.(png|jpe?g)$/,
                        resourceQuery: /lqip/,
                        use: [
                            {
                                loader: "lqip-loader",
                                options: {
                                    base64: true,
                                },
                            },
                        ],
                    },
                    {
                        test: /\.(png|jpe?g)$/,
                        resourceQuery: /webp/,
                        use: [
                            {
                                loader: "responsive-loader",
                                options: {
                                    adapter: !isEditor && require("responsive-loader/sharp"),
                                },
                            },
                            {
                                loader: "img-loader",
                                options: {
                                    plugins: [
                                        require("imagemin-mozjpeg")(),
                                        require("imagemin-svgo")(),
                                        require("imagemin-webp")(),
                                        require("imagemin-optipng")(),
                                    ],
                                },
                            },
                            {
                                loader: "webp-loader",
                            },
                        ],
                    },
                    {
                        test: /\.(png|jpe?g)$/,
                        resourceQuery: /responsive/,
                        use: [
                            {
                                loader: "responsive-loader",
                                options: {
                                    adapter: !isEditor && require("responsive-loader/sharp"),
                                },
                            },
                            {
                                loader: "img-loader",
                                options: {
                                    plugins: [
                                        require("imagemin-mozjpeg")(),
                                        require("imagemin-svgo")(),
                                        require("imagemin-webp")(),
                                        require("imagemin-optipng")(),
                                    ],
                                },
                            },
                        ],
                    },
                    {
                        test: /\.svg$/,
                        resourceQuery: /svgr/,
                        use: ["@svgr/webpack", urlLoaderOptions],
                    },
                    {
                        use: [urlLoaderOptions],
                    },
                ],
            },
        ],
    },
};
};
const webpack = require("webpack");
const paths = require("./paths");
const merge = require("webpack-merge");
const path = require("path");

const HtmlWebpackIncludeAssetsPlugin = require("html-webpack-include-assets-plugin");
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
const OptimizeCSSAssetsPlugin = require("optimize-css-assets-webpack-plugin");
const RobotstxtPlugin = require("robotstxt-webpack-plugin");
const WebpackPwaManifest = require("webpack-pwa-manifest");
const CircularDependencyPlugin = require("circular-dependency-plugin");

const CommonConfig = require("./webpack.config.common.js");

const CspHtmlWebpackPlugin = require("csp-html-webpack-plugin");
const csp = require("./csp");

module.exports = (env, argv) =>
    merge(CommonConfig(env, argv), {
        devtool: "source-map",
        plugins: [
            new CspHtmlWebpackPlugin(
                {
                    "script-src": ["'self'", "'unsafe-inline'", ...csp.allowedScriptSrc],
                    "style-src": ["'self'", "'unsafe-inline'", ...csp.allowedStylesSrc],
                },
                {
                    nonceEnabled: {
                        "script-src": false,
                        "style-src": false,
                    },
                    hashEnabled: {
                        // disable hashing as 'unsafe-inline' is present
                        "script-src": false,
                    },
                },
            ),
            new webpack.EnvironmentPlugin({
                PLATFORM: "web",
            }),
            new WebpackPwaManifest({
                filename: "manifest.webmanifest",
                name: "Shell Fleet Assistant",
                short_name: "FleetAssistant",
                start_url: ".",
                display: "standalone",
                orientation: "portrait",
            }),
            new HtmlWebpackIncludeAssetsPlugin({
                assets: ["config.js"],
                append: false,
            }),
            new RobotstxtPlugin({
                policy: [
                    {
                        userAgent: "*",
                        disallow: "/",
                    },
                ],
            }),
            new MiniCssExtractPlugin({
                filename: "[name]-[contenthash].css",
            }),
            new OptimizeCSSAssetsPlugin({}),
            new CircularDependencyPlugin({
                // exclude detection of files based on a RegExp
                exclude: /node_modules/,
                // add errors to webpack instead of warnings
                failOnError: true,
                // set the current working directory for displaying module paths
                cwd: process.cwd(),
            }),
        ],
    resolve: {
        alias: {
            config: paths.config("production"),
        },
    },

    stats: {
        children: false,
    },
});
我不想更改配置文件中的更多设置,因为我已将项目迁移到现有项目。请任何人提出解决这个问题的可能办法

提前谢谢