-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add
libraryFile
configuration option (#755)
* Add libraryFile config option. * Add test for libraryFile config option. * Add changeset. * Update changeset with PR feedback Co-authored-by: Adam Skoufis <askoufis@users.noreply.github.com> * Remove unnecessary @ts-ignore directive from library fixtures. * Update libraries documentation to use TypeScript for config examples. * Update SKU_LIBRARY_* global variable names to match other globals. --------- Co-authored-by: Adam Skoufis <askoufis@users.noreply.github.com>
- Loading branch information
Showing
28 changed files
with
296 additions
and
12 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
--- | ||
'sku': minor | ||
--- | ||
|
||
Add `libraryFile` configuration option | ||
|
||
This option allows the file name of the library to be specified in the sku configuration. | ||
If this option is not specified then the `libraryName` option will be used for this purpose instead (note that this is the previously existing behaviour). | ||
|
||
**EXAMPLE USAGE**: | ||
|
||
```typescript | ||
// sku.config.ts | ||
import type { SkuConfig } from 'sku'; | ||
|
||
const skuConfig: SkuConfig = { | ||
libraryEntry: 'src/library.js', | ||
renderEntry: 'src/render.js', | ||
libraryName: 'MyAwesomeLibrary', | ||
libraryFile: 'my-awesome-library', | ||
}; | ||
|
||
export default skuConfig; | ||
``` |
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
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 |
---|---|---|
@@ -1,4 +1,3 @@ | ||
// @ts-ignore | ||
import { style } from 'sku/treat'; | ||
|
||
export const customBox = style({ | ||
|
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,7 @@ | ||
# managed by sku | ||
*.less.d.ts | ||
coverage/ | ||
dist-storybook/ | ||
dist/ | ||
report/ | ||
# end managed by sku |
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,9 @@ | ||
# managed by sku | ||
.eslintrc | ||
.prettierrc | ||
coverage/ | ||
dist-storybook/ | ||
dist/ | ||
report/ | ||
tsconfig.json | ||
# end managed by sku |
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,7 @@ | ||
# managed by sku | ||
*.less.d.ts | ||
coverage/ | ||
dist-storybook/ | ||
dist/ | ||
report/ | ||
# end managed by sku |
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 @@ | ||
{ | ||
"name": "@sku-fixtures/library-file", | ||
"private": true, | ||
"dependencies": { | ||
"dedent": "^0.7.0", | ||
"sku": "workspace:*" | ||
} | ||
} |
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 @@ | ||
module.exports = { | ||
libraryEntry: 'src/library.js', | ||
renderEntry: 'src/render.js', | ||
libraryName: 'MyLibrary', | ||
libraryFile: 'my-library', | ||
port: 8086, | ||
persistentCache: false, | ||
}; |
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 @@ | ||
export const message = 'UNUSED'; |
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 @@ | ||
export const message = 'This element was generated by the library'; |
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,12 @@ | ||
import styles from './styles.less'; | ||
import { customBox } from './styles.treat'; | ||
|
||
export default () => { | ||
const dynamicImport = 'used'; | ||
import(`./dynamicImports/${dynamicImport}`).then(({ message }) => { | ||
const el = document.createElement('div'); | ||
el.className = `${styles.root} ${customBox}`; | ||
el.innerHTML = message; | ||
document.body.appendChild(el); | ||
}); | ||
}; |
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,19 @@ | ||
import dedent from 'dedent'; | ||
|
||
export default { | ||
renderDocument: ({ libraryName, headTags, bodyTags }) => dedent` | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<title>My Awesome Project</title> | ||
<meta name="viewport" content="width=device-width, initial-scale=1"> | ||
${headTags} | ||
</head> | ||
<body> | ||
${bodyTags} | ||
<script>window.${libraryName}();</script> | ||
</body> | ||
</html> | ||
`, | ||
}; |
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 @@ | ||
.root { | ||
color: red; | ||
} |
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,7 @@ | ||
// This file is automatically generated. | ||
// Please do not change this file! | ||
interface CssExports { | ||
'root': string; | ||
} | ||
export const cssExports: CssExports; | ||
export default cssExports; |
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 @@ | ||
import { style } from 'sku/treat'; | ||
|
||
export const customBox = style({ | ||
backgroundColor: 'lightseagreen', | ||
color: 'white', | ||
fontSize: 50, | ||
padding: 20, | ||
}); |
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
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 |
---|---|---|
@@ -1,14 +1,17 @@ | ||
import render from '__sku_alias__renderEntry'; | ||
|
||
const libraryName = SKU_LIBRARY_NAME; | ||
const libraryName = __SKU_LIBRARY_NAME__; | ||
const libraryFile = __SKU_LIBRARY_FILE__; | ||
const publicPath = __SKU_PUBLIC_PATH__; | ||
|
||
const libraryPath = `${publicPath}${libraryFile ?? libraryName}`; | ||
|
||
export default (renderParams) => { | ||
const renderContext = { ...renderParams, libraryName }; | ||
const renderContext = { ...renderParams, libraryName, libraryFile }; | ||
|
||
return render.renderDocument({ | ||
...renderContext, | ||
headTags: `<link rel="stylesheet" type="text/css" href="${publicPath}${libraryName}.css">`, | ||
bodyTags: `<script src="${publicPath}${libraryName}.js"></script>`, | ||
headTags: `<link rel="stylesheet" type="text/css" href="${libraryPath}.css">`, | ||
bodyTags: `<script src="${libraryPath}.js"></script>`, | ||
}); | ||
}; |
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.