onebay / vite-plugin-imp

A vite plugin for import library component style automatic.
MIT License
231 stars 24 forks source link

Option to only add extra styles without rewriting the JS imports? #17

Closed mgcrea closed 2 years ago

mgcrea commented 2 years ago

Describe the bug

Can't build my vite app using vite-plugin-imp as it tries to rewrite both style and js imports. In my use case, I only want to add extra less imports and do not touch the JS imports (and let rollup do the tree shaking).

        {
          libName: '@mgcrea/antd-extended',
          // libDirectory: 'lib/esm',
          // camel2DashComponentName: false,
          style: (name) => {
            return [`antd/es/${name}/style/index.less`, `@mgcrea/antd-extended/lib/esm/${name}/style/index.less`];
          },
        },

[vite]: Rollup failed to resolve import "@mgcrea/antd-extended/es/button" from "src/screens/LoginScreen.tsx".

Library Info(please complete the following information):

To Reproduce

npx vite build

Looks like replaceOldImport might be a possible fix if it did work for the build command as well.

psaren commented 2 years ago

I will make replaceOldImport work for build command as well to solve this situation.

mgcrea commented 2 years ago

Thanks for the quick fix!