-
-
Notifications
You must be signed in to change notification settings - Fork 359
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
模版代码下载下来导入到dva搭建的项目里面,启动时报错(npm start) #44
Comments
在antMotion_style.less去掉了@import './ant-d.less';样式的引入,需要用到样式的地方可以修改成 |
https://ant.design/docs/react/customize-theme-cn#1)-package.theme(推荐) |
好主意!! |
把文件包发我邮箱。。。我看看第二种定制具体啥问题。。。 |
多了一层 import 会导致 less 编译的顺序发生变化,很奇怪的问题,还需要再深入看看。目前 ant-d.less 可以先改成这样来解决: + @import "~antd/lib/style/themes/default.less";
@import "custom.less"; // 把 custom.less 里的 import default.less 这句拿到上面去
@import "~antd/lib/style/core/index.less"; |
恩。。。我把定制皮服整成推荐那个吧。。。免得又出问题 |
Jimdo/typings-for-css-modules-loader#63 |
暂时将less版本降到3.0以下 |
As @youngluo mentioned - downgrading |
我所遇到的错误是: // #44 我使用的是 TS 方式:目前这个配置可以解决,希望能帮忙遇到同样问题。 /* config-overrides.js */
const tsImportPluginFactory = require('ts-import-plugin');
const { getLoader } = require("react-app-rewired");
const rewireLess = require('react-app-rewire-less');
module.exports = function override(config, env) {
const tsLoader = getLoader(
config.module.rules,
rule =>
rule.loader &&
typeof rule.loader === 'string' &&
rule.loader.includes('ts-loader')
);
tsLoader.options = {
getCustomTransformers: () => ({
before: [
tsImportPluginFactory({
libraryDirectory: 'es',
libraryName: 'antd',
style: true,
}),
],
})
};
config = rewireLess.withLoaderOptions({
javascriptEnabled: true,
// modifyVars: { "@primary-color": "#1DA57A" },
})(config, env);
return config;
}; |
@zhaoyu69 有可能是less的问题, "less": "^2.7.3", "less-loader": "^4.1.0", 把less版本降到3.0以下,我这边就没问题了。 |
但是webpack4要求less要升级,不能在2.x~ |
开启 JavaScript 就可以了
|
@oopsguy 你这个办法是最简单的,谢谢分享。 |
@oopsguy 配置在那个位置? |
@lanmingle 十分感谢,您的办法有效。没想到跟着官网做居然有bug,可能是yarn创建项目时有问题吧,反正执行create-react-app my-project --scripts-version=react-scripts-ts-antd时给我报了好多警告,说什么window32位不兼容还是什么的。。。我的本子应该是64位的啊。。。 |
@afc163 less4已经不支持less中嵌入js了,现在只能降级成less3 才能避免这个报错 |
see this issue ant-design/ant-motion#44
|
laravel-mix:
|
np这个方法完美 |
vite 里遇到一样的问题,被你一语道破。 |
If using nuxt3 with Vite:
import { defineConfig } from 'vite'
export default defineConfig({
css: {
preprocessorOptions: {
less: {
modifyVars: {
white: '#333',
'component-background': '#777',
'primary-color': '#1DA57A',
'link-color': '#1DA57A',
'border-radius-base': '2px',
},
javascriptEnabled: true,
},
}
}
})
|
#170 Inline JavaScript is not enabled. Is it set in your options - ant-design/ant-motion#44 ```shell > @example/[email protected] build /home/runner/work/antdp/antdp/examples/website > kkt build Creating an optimized production build... Failed to compile. // ant-design/ant-motion#44 .bezierEasingMixin(); ^ Inline JavaScript is not enabled. Is it set in your options? Error in /home/runner/work/antdp/antdp/node_modules/antd/lib/style/color/bezierEasing.less (line 110, column 0) ``` https://github.com/antdpro/antdp/runs/4709998226?check_suite_focus=true
Vue CLI v5.0.1 // package.json
"dependencies": {
"ant-design-vue": "2.2.8",
...
"vue": "^3.2.13",
},
"devDependencies": {
...
"less": "^4.0.0",
"less-loader": "^8.0.0", // vue.config.js
const { defineConfig } = require('@vue/cli-service')
module.exports = defineConfig({
transpileDependencies: true,
css: {
loaderOptions: {
less: {
// javascriptEnabled: true // old solution
// HERE is the difference!
lessOptions: {
javascriptEnabled: true
}
}
}
}
}) It's work! |
Hi team, I bumped into the same problem and wasn't able to resolve it. I'm using storybook tool in my project and this is my configuration for it (pls pay attention to less-loader):
However, when I'm trying to compile the project (npm run storybook) that ERROR comes up again and again:
[email protected] Any ideas on that?.. |
The same, I have spent three hours on it, did not solved. |
good job~!!!!!!! |
I use vite to set up my program, try to change the theme color but found Finally, I found that I hadnt open the setting of the importStyle of the unplugin-vue-components.
|
I needed to use:
|
"less": "^4.1.2",
"vite": "^2.9.9",
"antd": "^4.20.5" css: {
preprocessorOptions: {
less: {
modifyVars: getThemeVariables({
'dark': false,
'primary-color': '205, 154, 1'
}),
javascriptEnabled: true,
},
},
} Still throws I cannot downgrade to a lower version of Less <3.0.0 because the latest version of Antd uses each function which isn't in older versions of Less. |
In webpack.mix.js, change: to
|
Here is what I have used to fix the issue in less > 4.0
|
Thank you. My issue was that I wasn't specifying my config file. Stupid thing but thanks for letting me know anyways! |
antdpro#170 Inline JavaScript is not enabled. Is it set in your options - ant-design/ant-motion#44 ```shell > @example/[email protected] build /home/runner/work/antdp/antdp/examples/website > kkt build Creating an optimized production build... Failed to compile. // ant-design/ant-motion#44 .bezierEasingMixin(); ^ Inline JavaScript is not enabled. Is it set in your options? Error in /home/runner/work/antdp/antdp/node_modules/antd/lib/style/color/bezierEasing.less (line 110, column 0) ``` https://github.com/antdpro/antdp/runs/4709998226?check_suite_focus=true
你好,我下载的Home项目引入到项目工程里面,为了方便,我全部放到了components下面,引入和基本流程没有问题。在家里的win10上面启动没有报错,在win7上面启动就报错了,错误原因:
in ./src/components/Index/less/antMotion_style.less
Module build failed: ModuleBuildError: Module build failed: JavaScript evaluation error: 'ReferenceError: colorPalette is not defined'
@ F:\Web\mabyloveProjects\mabylove\weblove\node_modules.2.6.0@antd\lib\button\style\index.less (line 11, column 2)
near lines:
.btn;
.btn-default;
@ ./src/components/Index/index.jsx 57:0-38
便于清晰的认识到:我特意截了图:
构建组件的时候,在index.jsx中出现错误:(其实就是antMotion_style.less样式报错)
接着就是错误的位置啦
接上一个的错误的具体位置
希望给一个解决方法。谢谢
The text was updated successfully, but these errors were encountered: