diff --git a/src/common/library/babel-plugin-remove-css-imports.ts b/src/common/library/babel-plugin-remove-css-imports.ts deleted file mode 100644 index bd66069..0000000 --- a/src/common/library/babel-plugin-remove-css-imports.ts +++ /dev/null @@ -1,14 +0,0 @@ -import {declare} from '@babel/helper-plugin-utils'; - -export default declare(function () { - return { - visitor: { - ImportDeclaration(path) { - const source = path.node.source.value; - if (source.endsWith('.css')) { - path.remove(); - } - }, - }, - }; -}); diff --git a/src/common/library/babel-plugin-remove-css-paths.test.ts b/src/common/library/babel-plugin-remove-css-paths.test.ts deleted file mode 100644 index c99bd2e..0000000 --- a/src/common/library/babel-plugin-remove-css-paths.test.ts +++ /dev/null @@ -1,19 +0,0 @@ -import pluginTester from 'babel-plugin-tester'; -import plugin from './babel-plugin-remove-css-imports'; - -pluginTester({ - plugin, - tests: { - 'remove css paths': { - code: ` - import './test.css'; - import '../path/test.css'; - import 'my-lib/test.css'; - import 'my-lib'; - `, - output: ` - import 'my-lib'; - `, - }, - }, -}); diff --git a/src/common/library/index.ts b/src/common/library/index.ts index 1a572e3..91e2cc2 100644 --- a/src/common/library/index.ts +++ b/src/common/library/index.ts @@ -73,7 +73,6 @@ function compileToCjs( babelrc: false, filename: sourceFile, plugins: [ - require.resolve('./babel-plugin-remove-css-imports'), require.resolve('@babel/plugin-transform-modules-commonjs'), require.resolve('@babel/plugin-transform-dynamic-import'), ], @@ -296,7 +295,17 @@ export function buildLibrary(config: LibraryConfig) { // css compilation compileStyles(paths.libGlobalStyles, paths.libCompiledGlobalStyles, () => { - compileStyles(paths.src, paths.libBuildEsm, undefined, internalGlobs); + compileStyles( + paths.src, + paths.libBuildEsm, + () => { + const stylesStream = globStream(['**/*.{css,css.map}'], { + cwd: paths.libBuildEsm, + }); + stylesStream.on('data', copyToCjs); + }, + internalGlobs, + ); }); // icons compilation to js