我正在使用 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) 我正在尝试使用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)