美文网首页
ant desgin css按需加载 webpack配置

ant desgin css按需加载 webpack配置

作者: _一九九一_ | 来源:发表于2019-07-12 16:42 被阅读0次

    webpack.config.js

    {
      test: /\.(js|mjs|jsx|ts|tsx)$/,
      include: paths.appSrc,
      loader: require.resolve('babel-loader'),
      options: {
        customize: require.resolve(
          'babel-preset-react-app/webpack-overrides'
        ),
        plugins: [
          ["import",{libraryName: "antd", style: 'css'}],   //只需加一行,手动划重点antd按需加载 
          [
            require.resolve('babel-plugin-named-asset-import'),
            {
              loaderMap: {
                svg: {
                  ReactComponent: '@svgr/webpack?-svgo,+ref![path]',
                },
              },
            },
          ],
        ], 
        cacheDirectory: true,
        cacheCompression: isEnvProduction,
        compact: isEnvProduction,
      },
    }
    

    相关文章

      网友评论

          本文标题:ant desgin css按需加载 webpack配置

          本文链接:https://www.haomeiwen.com/subject/eadykctx.html