如何在 webpack 开发服务器上使用 react-app-rewired?

问题描述

我想在没有“react-app-rewired start”脚本的项目中使用 react-app-rewired npm 包。

这是我的 package.json 文件

{
  ///
   script:{
      ///
      "watch": "webpack-dev-server",/// 
   }   
 ///  
}

我可以通过 sudo yarn watch 启动我的服务器。所以我不能用 react-app-rewired start 重写它。

这是我的 config-overrides.js 文件

const path = require("path");
const {
    override,fixBabelImports,addLessLoader,addWebpackPlugin
} = require("customize-cra");
const AntDesignThemePlugin = require("antd-theme-webpack-plugin");

const options = {
    stylesDir: path.join(__dirname,"./src/styles"),antDir: path.join(__dirname,"./node_modules/antd"),varFile: path.join(__dirname,"./src/styles/vars.less"),themeVariables: ["@primary-color"],// indexFileName: "index.html"
};

module.exports = override(
    fixBabelImports("antd",{
        libraryName: "antd",libraryDirectory: "es",style: true
    }),addWebpackPlugin(new AntDesignThemePlugin(options)),addLessLoader({
        lessOptions: {
            javascriptEnabled: true
        }
    })
);

我也可以使用 webpack.config.js 文件。如果有人知道我如何在该文件添加此配置,则非常欢迎。 谢谢!

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)