-
-
Notifications
You must be signed in to change notification settings - Fork 314
This issue was moved to a discussion.
You can continue the conversation there. Go to discussion →
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
[RFC] webpack-like tilde resolves in less #143
Comments
You can try |
xxxxx package insert "dependencies": {
"xxxxx": "0.0.1"
} yarn dev 🔴 ERROR | Inline JavaScript is not enabled. Is it set in your options? |
parcel-bundler/parcel#907 (comment) |
@crazyair just tried this example, it seems to work for me: https://github.com/PlasmoHQ/examples/tree/main/with-ant-design The tilde import means from the root of the current project for Plasmo (and latest Parcel), NOT from |
|
can you give me the project you're trying to use? Or is it antd itself? |
Also, if they use |
You can install popup.tsx import { ProCard } from '@ant-design/pro-components';
<ProCard title="默认尺寸" extra="extra" tooltip="这是提示" style={{ maxWidth: 300 }}>
<div>Card content</div>
<div>Card content</div>
<div>Card content</div>
</ProCard> 🔴 ERROR | The @import path "\~antd/es/style/themes/index.less" is using webpack specific syntax, which isn't supported by Parcel.
To @import files from node\_modules, use "antd/es/style/themes/index.less"
··· |
demo: PlasmoHQ/examples#15 |
This is a "missing feature" within Parcel's less transformer: https://github.com/parcel-bundler/parcel/blob/v2/packages/transformers/less/src/LessTransformer.js#L115 OR more likely, inconsistency with parcel's definition of the Some potential solutions:
@crazyair can you link me the doc for the tilde path import in less? Also, would you be down to investigate and implement a solution? |
NOTE: These examples you're referencing uses |
external project Deleting
🔴 ERROR | Inline JavaScript is not enabled. Is it set in your options? |
Do you have the lessrc option in your project? |
The main project has, but the external project does not |
Can you do a bundling of the external project into some plain component, and just import the output inside plasmo and use it that way then? |
how? |
Create a sibling-level project to your extension project, compile them with webpack (or any bundler that has the behavior described), then import them into the plasmo project. https://lesscss.org/features/ <- based on this, I confirm the tilde resolve you're referencing from antd-pro is not a thing in less, and is only a thing within antd's webpack configuration (and maybe the webpack ecosystem?). antd pro less loader is here: https://github.com/ant-design/pro-components/blob/master/webpack.config.js#L108 Also, try using the specific component that's been compiled and see if it works for you: https://www.npmjs.com/package/@ant-design/pro-card |
Also, don't use the |
Why? We currently require the use of ES |
Why would that matters for a dependency? Their ES version requires custom resolver for those less path |
Only one path is referenced, lib or es. |
you can import directly like |
I've tried everything but still haven't solved it 😭 |
no dist,need change less variable |
^ There's a dist directory if you installed the specific |
have you tried hacking the less transformer? Basically, make it align with the way webpack bundle less source as antd. Also I have no idea how other project uses antd-pro unless they have a similar webpack bundler OR postcss plugin to reconfigure those paths. |
No problem with webpack or umi |
@crazyair in Umi for it to work with latest antd-pro, you also need to hack up the less path on webpack config: https://v3.umijs.org/guide/upgrade-antd-pro-to-umi-3#%E9%85%8D%E7%BD%AE%E5%B1%82%E8%BF%81%E7%A7%BB So yeah for it to work with parcel, you will need to play around with the less transformer as well and maybe handle the antd special case, OR if antd managed to make their convention widespread enough, implement it as default |
How is parcel configured and can it be built-in? |
Yes, see this comment: #143 (comment) |
Second, I've tried, but I can't |
@crazyair I encountered the same problem, the solution is parcel-bundler/parcel#6623 (comment) |
|
@crazyair You can use a script similar to the one executed after postinstall.
|
This issue was moved to a discussion.
You can continue the conversation there. Go to discussion →
What happened?
index.less content
@import '~antd/dist/antd.less';
Version
Latest
What OS are you seeing the problem on?
MacOSX
What browsers are you seeing the problem on?
Microsoft Edge
Relevant log output
But this project is OK
https://github.com/ant-design/parcel-antd/blob/master/src/style/index.less#L1
(OPTIONAL) Contact Details
No response
Code of Conduct
The text was updated successfully, but these errors were encountered: