小编Mat*_*mer的帖子

无法使用craco在create-react-app中导入其他项目的组件

我在将组件从一个 React 项目导入另一个项目时遇到问题。这些问题似乎非常基本,但我真的很难弄清楚问题出在哪里以及实现我的目标的确切 craco 配置是什么。

导出项目

我正在导出App,这是一个功能性 React 组件。

源代码/索引.js

import App from "./App";
export default App;
Run Code Online (Sandbox Code Playgroud)

我用craco主要是因为Tailwindcss和antd,这是配置文件:

craco.config.js

const { BundleAnalyzerPlugin } = require("webpack-bundle-analyzer");
const WebpackBar = require("webpackbar");
const CracoAntDesignPlugin = require("craco-antd");

const path = require("path");

module.exports = {
  style: {
    postcss: {
      plugins: [require("tailwindcss"), require("autoprefixer")],
    },
  },
  webpack: {
    plugins: [
      new WebpackBar({ profile: true }),
      ...(process.env.NODE_ENV === "development"
        ? [new BundleAnalyzerPlugin({ openAnalyzer: false })]
        : []),
    ],
    configure: (webpackConfig, { env, paths }) => { …
Run Code Online (Sandbox Code Playgroud)

reactjs webpack craco

15
推荐指数
1
解决办法
629
查看次数

标签 统计

craco ×1

reactjs ×1

webpack ×1