Skip to content
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

.css file not added into distribution in JS only library #305

Closed
ghost opened this issue Aug 16, 2020 · 1 comment
Closed

.css file not added into distribution in JS only library #305

ghost opened this issue Aug 16, 2020 · 1 comment

Comments

@ghost
Copy link

ghost commented Aug 16, 2020

I'm writing JS library using rollup-starter-lib as base of my JS library

It has main.js file & main.css file, There is no html file.
main.js file is all about DOM manipulation, main.css file is necessary in implementation steps, to easily integrate this JS library, rather giving an instruction to user.

I feel like it's .css file not creating due to tree shaking because of css not used in this JS library itself.

Current Distribution

-dist
--my-faceapi-js-lib.cjs.js
--my-faceapi-js-lib.esm.js
--my-faceapi-js-lib.umd.js

Expected Distribution

-dist
--my-faceapi-js-lib.cjs.js
--my-faceapi-js-lib.esm.js
--my-faceapi-js-lib.umd.js
--my-faceapi-js-lib.css

copy main.css file into dist folder not expecting since it's not minifying.

rollup.config.js

import resolve from '@rollup/plugin-node-resolve';
import commonjs from '@rollup/plugin-commonjs';
import pkg from './package.json';
import path from 'path'
import postcss from 'rollup-plugin-postcss'

export default [
	{
		input: 'src/main.js',
		output: {
			name: 'howLongUntilLunch',
			file: pkg.browser,
			format: 'umd'
		},
		plugins: [
                         postcss({
				extract: path.resolve('dist/my-faceapi-js-lib.css'),
			}),
			resolve(), // so Rollup can find `ms`
			commonjs() // so Rollup can convert `ms` to an ES module
		]
	}
];

main.js

import * as faceapi from "face-api.js";
...
...
...
import 'main.css';
...
...

Basically there is not usage of main.css within JS library it self. but it's necessary when integrate this library.

@ghost ghost closed this as completed Aug 16, 2020
@pawelkrystkiewicz
Copy link

@chanukagzone how did you solve this? I'm facing the same issue

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant