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

feat: add title attribute to Compiled style tag #1649

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/fluffy-lies-shake.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@compiled/parcel-optimizer': minor
---

Add title attribute to Compiled style tag to discern with other style within the page
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ yarn test <filter> --watch

Looking at tests first is generally the best way to get started.

- Run a specific test file: `yarn test <filename> --watch`
- Run a specific test file: `yarn test <filename> --watch` OR `yarn test:parcel <filename>` if the test file name ends with `parceltest.{ts,tsx}`
- Run tests related to a package `yarn test:packageName --watch`
- Update snapshot tests after implementing a code change: `yarn test <filter> --watch --updateSnapshot`

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ describe('optimizer', () => {
'utf8'
);

const css = /<style>(.*?)<\/style>/.exec(outputHtml)?.pop();
const css = /<style title="compiled">(.*?)<\/style>/.exec(outputHtml)?.pop();

if (!css) throw new Error('No CSS is found.');

Expand Down
2 changes: 1 addition & 1 deletion packages/parcel-optimizer/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ export default new Optimizer<ParcelOptimizerOpts, unknown>({
.use(
insertAt({
selector: 'head',
append: '<style>' + stylesheet + '</style>',
append: '<style title="compiled">' + stylesheet + '</style>',
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Btw, do we inline CSS also in webpack? I don't think I have seen inlineCss for it

behavior: 'inside',
})
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ it('transforms assets with compiled and extraction babel plugins', async () => {
'utf8'
);

const css = /<style>(.*?)<\/style>/.exec(outputHtml)?.pop();
const css = /<style title="compiled">(.*?)<\/style>/.exec(outputHtml)?.pop();

if (!css) throw new Error('No CSS is found.');

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ it('transforms assets with compiled and extraction babel plugins', async () => {
'utf8'
);

const css = /<style>(.*?)<\/style>/.exec(outputHtml)?.pop();
const css = /<style title="compiled">(.*?)<\/style>/.exec(outputHtml)?.pop();

if (!css) throw new Error('No CSS is found.');

Expand Down Expand Up @@ -310,7 +310,7 @@ it('transforms assets with class name compression enabled', async () => {
'utf8'
);

const css = /<style>(.*?)<\/style>/.exec(outputHtml)?.pop();
const css = /<style title="compiled">(.*?)<\/style>/.exec(outputHtml)?.pop();

if (!css) throw new Error('No CSS is found.');

Expand Down
Loading