How to configure webpack for create-react-app #

ylamdve6  于 22天前  发布在  React
关注(0)|答案(2)|浏览(17)

我想为create-react-app配置webpack。我正在使用sass和其他包。有没有办法创建没有哈希的插件名称?

6yt4nkrj

6yt4nkrj1#

@mmehmoodahmed 创建react app已经配置了webpack。一开始我有点困惑,因为旧版本的CRA在项目根目录生成了一个webpack.config.js文件。这些天,配置文件位于https://github.com/facebook/create-react-app/blob/main/packages/react-scripts/config/webpack.config.js - 在your_project_dir/node_modules/react-scripts/config/中查找它以在您的localhost上找到它。您可以通过修改项目目录根目录中的config-overrides.js文件来添加其他插件。例如:

const { override, fixBabelImports } = require('customize-cra');

module.exports = function (config, env) {
  fixBabelImports('import', {
    libraryName: 'antd',
    libraryDirectory: 'es',
    style: 'css',
  })

  config.module.rules.push({
    // add your rule object - see the full config object at https://github.com/facebook/create-react-app/blob/c20ccecfa1cf130a47d37908dc54959c618ce8ea/packages/react-scripts/config/webpack.config.js#L199
  })
  
  // customize more as needed...

  return config
}

不过,我无法在没有哈希的情况下创建插件的纯名称。祝您好运!

epggiuax

epggiuax2#

谢谢你,biclon。

我想覆盖web.config.js文件,我的部署不需要分块文件,我只需要一个文件。

我想通过http://www.someurl.com/pluginA.js访问它。

我希望我的用户可以直接调用我的reactjs小部件,而不需要iframe。

对于这个问题有什么帮助吗??

提前感谢你。

相关问题