arackaf / customize-cra

Override webpack configurations for create-react-app 2.0
MIT License
2.78k stars 268 forks source link

addLessLoader 生产模式 打包出的css 未压缩 #264

Open Jarryxin opened 4 years ago

Jarryxin commented 4 years ago
addLessLoader({
   javascriptEnabled: true,
   modifyVars: { '@brand-primary': 'hotpink', "@brand-primary-tap": 'pink' }, // 修改主题
 }),
{
  "react-scripts": "3.4.1",
  "style-loader": "^1.2.1",
  "react-app-rewired": "^2.1.6",
  "px2rem-loader": "^0.1.9",
  "less-loader": "^5.0.0",
  "less": "^3.12.2",
  "customize-cra": "^0.9.1",
  "css-loader": "^3.6.0",
}
Miindaugas commented 4 years ago

I have compile errors with lessLoader as well when trying use Antd design css works fine but less just breaks build.

    "less": "^3.12.2",
    "less-loader": "^6.2.0",
    "react-app-rewired": "2.1.6",
fixBabelImports('import', {
    libraryName: 'antd',
    libraryDirectory: 'es',
    style: true,
}),

addLessLoader({
  lessOptions: {
    javascriptEnabled: true,
    modifyVars: { '@primary-color': '#A80000' },
  },
})

Failed to compile. ./node_modules/antd/es/style/index.less TypeError: this[MODULE_TYPE] is not a function

Jarryxin commented 4 years ago

I have compile errors with lessLoader as well when trying use Antd design css works fine but less just breaks build.

    "less": "^3.12.2",
    "less-loader": "^6.2.0",
    "react-app-rewired": "2.1.6",
fixBabelImports('import', {
    libraryName: 'antd',
    libraryDirectory: 'es',
    style: true,
}),

addLessLoader({
  lessOptions: {
    javascriptEnabled: true,
    modifyVars: { '@primary-color': '#A80000' },
  },
})

Failed to compile. ./node_modules/antd/es/style/index.less TypeError: this[MODULE_TYPE] is not a function

hi~ down package version install "customize-cra": "^0.9.1", use addLessLoader({ javascriptEnabled: true, modifyVars: { '@brand-primary': 'hotpink', "@brand-primary-tap": 'pink' }, // 修改主题 }),