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

It is hoped that CSS and JS can be packaged together in lib mode #5015

Closed
4 tasks done
GuoJikun opened this issue Sep 22, 2021 · 4 comments
Closed
4 tasks done

It is hoped that CSS and JS can be packaged together in lib mode #5015

GuoJikun opened this issue Sep 22, 2021 · 4 comments
Labels
duplicate This issue or pull request already exists enhancement: pending triage

Comments

@GuoJikun
Copy link

Clear and concise description of the problem

Now in lib mode, CSS is packaged separately,However, I hope to package CSS and JS together.

Suggested solution

Configuration can be added:

export default defineConfig({
  build: {
    lib: {
      isSplitCss: Boolean
    },
  },
});

Alternative

No response

Additional context

No response

Validations

@hyrious
Copy link
Contributor

hyrious commented Sep 25, 2021

If you mean to inject css to a style element (like style loader), you can manually do that with the ?inline query:

import css from "./style.css?inline"
var style = document.createElement("style")
style.innerText = css
document.head.append(style)

@GuoJikun
Copy link
Author

GuoJikun commented Sep 26, 2021

If you mean to inject css to a style element (like style loader), you can manually do that with the ?inline query:

import css from "./style.css?inline"
var style = document.createElement("style")
style.innerText = css
document.head.append(style)

I have a Vue component ready to be released to NPM (eg: example). After packaging the component in lib mode, the CSS will be packaged into a separate file. I hope there is no CSS file.

example

// barcode.vue
<template>
  <p class="test"></p>
</template>
<style>
.test{
  color: red;
}
</style>

output

now

- dist
  - barcode.js
  - style.css

but i hope

- dist
  - barcode.js

@y1d7ng
Copy link
Contributor

y1d7ng commented Sep 28, 2021

same issue #4345

@y1d7ng y1d7ng closed this as completed Sep 28, 2021
@Shinigami92 Shinigami92 added the duplicate This issue or pull request already exists label Sep 28, 2021
@tylerrrkd
Copy link

tylerrrkd commented Oct 3, 2021

both issues closed #4345 and #5051, and actually, there is another duplicate issue #1579.

@github-actions github-actions bot locked and limited conversation to collaborators Oct 18, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
duplicate This issue or pull request already exists enhancement: pending triage
Projects
None yet
Development

No branches or pull requests

5 participants