-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #139 from marcalexiei/feature/insert-style-dedupe
issue-132 - dedupe insertStyle in output files
- Loading branch information
Showing
12 changed files
with
141 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
/** | ||
* Create a style tag and append to head tag | ||
* | ||
* @warning this file is not included directly in the source code! | ||
* If user specifies inject option to true, an import to this file will be injected in rollup output. | ||
* Due to this reason this file is compiled into a ESM module separated from other plugin source files. | ||
* That is the reason of why there are two tsconfig.build files. | ||
* | ||
* @return css style | ||
*/ | ||
export default function insertStyle(css: string | undefined): string | undefined { | ||
if (!css || typeof window === 'undefined') { | ||
return; | ||
} | ||
|
||
const style = document.createElement('style'); | ||
style.setAttribute('type', 'text/css'); | ||
style.innerHTML = css; | ||
|
||
document.head.appendChild(style); | ||
|
||
return css; | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import a from '../../assets/actual_a.scss'; | ||
|
||
export default a; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import b from '../../assets/actual_b.scss'; | ||
|
||
export default b; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# Snapshot report for `test/index.test.ts` | ||
|
||
The actual snapshot is saved in `index.test.ts.snap`. | ||
|
||
Generated by [AVA](https://avajs.dev). | ||
|
||
## should import *.scss and *.sass files with default configuration | ||
|
||
> Snapshot 1 | ||
'var atualA = "body {\\n color: red;\\n}";var atualB = "body {\\n color: green;\\n}";var atualC = "body {\\n color: blue;\\n}";var index = atualA + atualB + atualC;export { index as default };' | ||
|
||
## should insert CSS into head tag | ||
|
||
> Snapshot 1 | ||
`import ___$insertStyle from '../../../src/insertStyle.js';␊ | ||
␊ | ||
___$insertStyle("body{color:red}");␊ | ||
␊ | ||
___$insertStyle("body{color:green}");␊ | ||
` |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
/* @see insertStyle.ts for additional information */ | ||
{ | ||
"extends": "./tsconfig.json", | ||
"include": ["./src/insertStyle.ts"], | ||
"compilerOptions": { | ||
"module": "ES6" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
/* @see insertStyle.ts for additional information */ | ||
{ | ||
"extends": "./tsconfig.json", | ||
"include": ["./src/*"], | ||
"exclude": ["./src/insertStyle.ts"] | ||
} |