arco-design / arco-plugins Goto Github PK
View Code? Open in Web Editor NEWWebpack / Vite plugins for Arco Design
Home Page: https://arco.design
License: MIT License
Webpack / Vite plugins for Arco Design
Home Page: https://arco.design
License: MIT License
none
modernjs 都推 v2 了,都加了 rspack 了,内部不支持一波吗 :)
希望可以支持vite脚手架的使用,目前使用vite脚手架做开发也不少
https://nextjs.org/blog/next-12
@arco-design/[email protected]
Create an app with CRA:
npx create-react-app demo
cd demo
yarn eject
Install arco design and the plugin:
yarn add @arco-design/web-react
yarn add -D @arco-design/webpack-plugin
Modify config/webpack.config.js
to add the plugin:
...
const ArcoWebpackPlugin = require('@arco-design/webpack-plugin');
...
module.exports = function (webpackEnv) {
...
return {
...
plugins: [
...
new ArcoWebpackPlugin(),
].filter(Boolean),
...
};
};
Change src/App.js
content to:
import { Button } from '@arco-design/web-react';
function App() {
return (
<Button>Button</Button>
);
}
export default App;
Run with yarn start
, it seems that style auto import dosen't work:
App.vue 文件中引用了一个自定义的Switch 组件,该组件包含了三个不同的switch,在在使用按需引用之前是可以正常显示的,在使用按需引用插件之后,自定义的Switch不在是自己的封装的,变成acro框架默认的switch了。
Dockerfile
FROM node AS builder
WORKDIR /opt/web
COPY package.json package-lock.json ./
RUN npm config set registry https://registry.npm.taobao.org
RUN npm install
ENV PATH="./node_modules/.bin:$PATH"
COPY . ./
ARG ENV
ENV ENV=$ENV
RUN npm run build
FROM caddy as admin-web
WORKDIR /var/www/html
COPY --from=builder /opt/web/Caddyfile /etc/caddy/Caddyfile
COPY --from=builder /opt/web/dist ./dist
ENV TZ=Asia/Shanghai
EXPOSE 80
使用的vite
的模板,会在npm install
的时候卡死。观察监控看到读磁盘被打满,180MB/s 的读 IO。
不知道有没有别个小伙伴有遇到这个问题。
无法使用codepen配置这个插件复现问题, 希望解决
"dependencies": {
"@arco-design/web-react": "^2.27.2",
"react": "^17.0.2",
"react-dom": "^17.0.2"
},
"devDependencies": {
"@arco-plugins/vite-react": "^1.0.2",
"@arco-themes/react-choral-music": "^0.0.2",
"@types/react": "^17.0.33",
"@types/react-dom": "^17.0.10",
"@vitejs/plugin-react": "^1.0.7",
"typescript": "^4.5.4",
"vite": "^2.7.2"
}
No error.
Use the reproduction link, or
@arco-design/web-react
and开发环境下并非按需导入样式而是导入全部,只有构建环境下才会按需导入。
开始以为是个人配置问题,折腾无果后翻阅源码发现似乎是故意为之,但是文档并未说明这一点。
请问为什么不在开发环境下也启用按需引入呢?
this is not increment dist/assets/ArcoDateRange.5d14a6ee.css 109.62 KiB / gzip: 12.99 KiB
// ArcoDateComponent.tsx
import { DatePicker, RangePickerProps } from '@arco-design/web-react'
// https://vitejs.dev/config/
export default defineConfig(() => {
return {
plugins: [
react({ fastRefresh: false }),
vitePluginForArco({
style: 'css',
}),
],
resolve: {
},
build: {
// sourcemap: true,
rollupOptions: {
plugins: [
process.env.Analyze === '1'
? visualizer({
gzipSize: true,
})
: null,
].filter(Boolean),
},
},
}
})
@arco-plugins/webpack-react 和 @arco-plugins/vite-react 的文档都提到了 iconBox
这个属性,并使用 @arco-design/iconbox-react-dcd-icon
作为例子。但是 @arco-design 在 npm 上并没有任何 iconbox的包。在 iconBox 官网 也没看到有关的包,只有 raw svg。请问这些包是还没发出来吗?
暂无
vite4.0.0 在vite.config.ts中配置@arco-plugins/vite-react配置时,显示TypeError: vitePluginForArco is not a function,希望可以支持vite4.0.0
报错:
下午5:43:45 [vite] Internal server error: path.replaceAll is not a function
Plugin: @arco-plugins/vite-vue
File: C:/fengzq/vue/practice/vite/vite-project/src/main.ts
at parse2PosixPath (C:\fengzq\vue\practice\vite\vite-project\node_modules@arco-plugins\vite-vue\lib\arco-design-plugin\utils.js:42:74)
at pathMatch (C:\fengzq\vue\practice\vite\vite-project\node_modules@arco-plugins\vite-vue\lib\arco-design-plugin\utils.js:48:51)
at transformCssFile (C:\fengzq\vue\practice\vite\vite-project\node_modules@arco-plugins\vite-vue\lib\arco-design-plugin\transform.js:34:47)
at TransformContext.transform (C:\fengzq\vue\practice\vite\vite-project\node_modules@arco-plugins\vite-vue\lib\arco-design-plugin\index.js:46:58)
at Object.transform (file:///C:/fengzq/vue/practice/vite/vite-project/node_modules/vite/dist/node/chunks/dep-4da11a5e.js:41111:44)
at runMicrotasks ()
at processTicksAndRejections (internal/process/task_queues.js:95:5)
at async loadAndTransform (file:///C:/fengzq/vue/practice/vite/vite-project/node_modules/vite/dist/node/chunks/dep-4da11a5e.js:37373:29)
vite.config.ts中配置
import { vitePluginForArco } from '@arco-plugins/vite-vue'
plugins: [
vue(),
AutoImport({
resolvers: [ArcoResolver()],
}),
Components({
resolvers: [
ArcoResolver({
sideEffect: true
})
]
}),
vitePluginForArco({ theme: '@arco-themes/vue-byway' })
]
出现[vite] Internal server error: path.replaceAll is not a function
期望控制台打印的行数与实际代码的行数一致,希望能够解决这个问题,谢谢
复现地址:https://stackblitz.com/edit/vitejs-vite-ixdnin?file=src/App.vue
按F12,打开控制台会看到 打印的”测试1“和”测试2“的行数一样,但是代码中“测试1”“测试2”的实际的行数是3和4。
去掉 @arco-plugins/vite-vue 插件后,控制台打印的行数与实际代码的行数一致。
只有在 .vue 文件中有这个问题
@jinghm318 @flsion 请审阅以下问题,如果同意修改,这边可以提交两个仓库的 PR 支持
无法独立支持模板方式的按需加载
仅支持样式的按需加载,组件代码加载需要依赖 unplugin-vue-components
部分组件不支持按需加载
不以组件目录名为前缀命名的组件,按需加载失效,如:<a-range-picker />
、<a-doption>
PS:虽然子组件其实只需要父组件成功加载样式就能正常显示,但是这样不是很严谨。
相关仓库:https://github.com/tazyong/test-vite3
独立支持 import 和 template 两种方式按需加载
修改组件库 components.ts 文件,引用路径具体到组件目录
修改构建插件库匹配组件逻辑,由以上文件获取组件路径
works fine when I use the on-demand loading of styles
It can't work at all when i use 1.4.1.
参考下这个:https://www.npmjs.com/package/next-plugin-antd-less,antd 的一个第三方插件,不过没有按需加载的实现,因为配置babel就行,但是arco,按照需求配置babel无效。
我使用 Next.js 12 无法成功实现 按需加载,不只是我配置的问题还是什么?始终显示:Cannot use import statement outside a module,查阅了好多资料
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.