This repository has been archived by the owner on Nov 4, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 409
修改主题时,按第三种方法失败 #52
Comments
用的 antd-init 的脚手架么? |
// Learn more on how to config.
// - https://github.com/ant-tool/atool-build#配置扩展
const webpack = require('atool-build/lib/webpack');
const fs = require('fs');
const path = require('path');
const glob = require('glob');
module.exports = function (webpackConfig) {
webpackConfig.babel.plugins.push('transform-runtime');
webpackConfig.babel.plugins.push(['antd', {
style: 'css', // if true, use less
}]);
// Enable this if you have to support IE8.
// webpackConfig.module.loaders.unshift({
// test: /\.jsx?$/,
// loader: 'es3ify-loader',
// });
// Parse all less files as css module.
webpackConfig.module.loaders.forEach(function(loader, index) {
if (typeof loader.test === 'function' && loader.test.toString().indexOf('\\.less$') > -1) {
loader.test = /\.dont\.exist\.file/;
}
if (loader.test.toString() === '/\\.module\\.less$/') {
loader.test = /\.less$/;
}
});
// Load src/entries/*.js as entry automatically.
const files = glob.sync('./src/entries/*.js');
const newEntries = files.reduce(function(memo, file) {
const name = path.basename(file, '.js');
memo[name] = file;
return memo;
}, {});
webpackConfig.entry = Object.assign({}, webpackConfig.entry, newEntries);
return webpackConfig;
}; |
@sorrycc 可以具体说明下版本更新后,如何能改组件库里的less的变量值呢? |
|
// Parse all less files as css module.
webpackConfig.module.loaders.forEach(function(loader, index) {
if (typeof loader.test === 'function' && loader.test.toString().indexOf('\\.less$') > -1) {
loader.test = /\.dont\.exist\.file/;
}
if (loader.test.toString() === '/\\.module\\.less$/') {
loader.test = /\.less$/;
}
}); 这段删掉试试。 |
@sorrycc 那段删掉就好了。 |
这里例子是可以修改主色的,我测试过最新的配置,你参照一下吧。https://github.com/ant-design/antd-init/tree/c0bde69268b528de4bf137e918dc7df9f339101d/examples/customize-antd-theme#less |
npm@2 下会报类似楼主的错误。 |
|
afc163
added a commit
to ant-design/ant-design
that referenced
this issue
May 25, 2016
感谢各位的帮忙!!! |
解决个人推荐方法二。 方法一:在 const fallback = webpackConfig.resolve.fallback || [];
webpackConfig.resolve.fallback = fallback.concat(path.join(__dirname, 'node_modules/antd/node_modules')); 方法二:项目安装 normalize.css 依赖, 原因antd 的 less 文件走了 less-loader 之后,会被合并到项目的 less 编译结果里,这之后就不会再基于 node_modules/antd 的目录做模块解析了。 |
赞~ 我上面加 inline 之后就好了,原来不走 less 解析能解决路径问题。 方法三等下个版本。 |
@sorrycc @afc163 更新代码后,还是存在部分less变量可以改值,比如@font-size-base,@link-color等,有些不可以,比如@primary-color,@border-radius-base,@border-radius-sm好像就改不了,请教如何解决,能说明的具体点么? |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
@sorrycc
修改主题,按第三种方法,
index.less:
@import "~antd/lib/style/themes/default.less";
@import "your-theme-file"; // 变量文件
@import "~antd/lib/style/core/index.less";
@import "~antd/lib/style/components.less";
失败,总是报错,错误如下:
ERROR in ./src/entries/index.less
Module build failed: ModuleNotFoundError: Module not found: Error: Cannot resolve 'file' or 'directory' ../../node_modules/antd/lib/style/core/~normalize.css/normalize.css in /Users/liujihong/Documents/ant-simple/src/entries
at /Users/liujihong/Documents/ant-simple/node_modules/webpack/lib/Compilation.js:229:38
at onDoneResolving (/Users/liujihong/Documents/ant-simple/node_modules/webpack/lib/NormalModuleFactory.js:29:20)
at /Users/liujihong/Documents/ant-simple/node_modules/webpack/lib/NormalModuleFactory.js:85:20
at /Users/liujihong/Documents/ant-simple/node_modules/async/lib/async.js:726:13
at /Users/liujihong/Documents/ant-simple/node_modules/async/lib/async.js:52:16
at done (/Users/liujihong/Documents/ant-simple/node_modules/async/lib/async.js:241:17)
at /Users/liujihong/Documents/ant-simple/node_modules/async/lib/async.js:44:16
at /Users/liujihong/Documents/ant-simple/node_modules/async/lib/async.js:723:17
at /Users/liujihong/Documents/ant-simple/node_modules/async/lib/async.js:167:37
at /Users/liujihong/Documents/ant-simple/node_modules/enhanced-resolve/lib/UnsafeCachePlugin.js:24:19
@ ./src/entries/index.js 5:0-23
Child extract-text-webpack-plugin:
chunk {0} extract-text-webpack-plugin-output-filename 1.16 MB [rendered]
[0] ./
/css-loader?sourceMap&modules&localIdentName=[local]___[hash:base64:5]!.//postcss-loader!.//less-loader?{"sourceMap":true,"modifyVars":{}}!./src/entries/index.less 1.16 MB {0} [built] [1 error]/css-loader/lib/css-base.js 1.51 kB {0}[6] ./
没有更新版本的时候,这个方法是可行的。更新到1.1版本后,文档没有更新,按这种方法就失败了,请指点
The text was updated successfully, but these errors were encountered: