小编Bab*_*der的帖子

从 webpack-cli 中获取错误:webpack 配置中的“TypeError:merge is not a function”

我正在使用 webpack-merge 将两个 webpack.config 文件组合在一起,但我不断收到错误“TypeError:merge is not a function when I run the command”webpack --config ./config/webpack.config.prod.js ”

有没有其他人遇到过这个问题?

webpack.config.prod.js

const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const OptimizeCssAssetsPlugin = require('optimize-css-assets-webpack-plugin');
const getCSSModuleLocalIdent = require('react-dev-utils/getCSSModuleLocalIdent');
const TerserPlugin = require('terser-webpack-plugin');
const commonConfig= require('./webpack.config.common');
const merge = require('webpack-merge');

module.exports = merge(commonConfig, {

    //config code
 
})
Run Code Online (Sandbox Code Playgroud)

reactjs webpack webpack-4 webpack-cli webpack-merge

36
推荐指数
1
解决办法
2万
查看次数

未应用第 3 方 CSS

我正在尝试使用react-responsive-carousel库,为了正确显示,它需要导入

import 'react-responsive-carousel/lib/styles/carousel.min';
Run Code Online (Sandbox Code Playgroud)

当我加载应用程序时,我没有看到应用于组件的样式。我猜这与我的 webpack 配置有关,但我还没有找到解决方案

webpack.config.common.js

module.exports = {
    entry: ['core-js/stable', 'regenerator-runtime/runtime', paths.appIndexJs],
    output: {
        filename: '[name].[contenthash].js',
        path: paths.appBuild,
        publicPath: './'
    },
    resolve: {
        extensions: ['.js', '.jsx', '.ts', '.tsx', '.scss','.css'],
        modules: ['node_modules']
    },
    plugins: [
        new CleanWebpackPlugin(),
        new HtmlWebPackPlugin({
            filename: 'index.html',
            inject: true,
            template: paths.appHtml
        }),
        new ESLintPlugin({
            formatter: eslintFormatter,
            eslintPath: 'eslint',
            resolvePluginsRelativeTo: __dirname
        })
    ],
    module: {
        rules: [
            {
                test: /\.(js|ts)x?$/,
                exclude: /node_modules/,
                use: {
                    loader: 'babel-loader',
                    options: {
                        cacheDirectory: true
                    }
                }
            },
            {
                test: [/\.bmp$/, …
Run Code Online (Sandbox Code Playgroud)

css import webpack

6
推荐指数
1
解决办法
601
查看次数

标签 统计

webpack ×2

css ×1

import ×1

reactjs ×1

webpack-4 ×1

webpack-cli ×1

webpack-merge ×1