Skip to content
This repository was archived by the owner on Jan 9, 2023. It is now read-only.

Commit afee9ff

Browse files
fix(component): ship components package with header injected styles
Ship components package with header injected styles (also relate to "fix #254" "fix #569"). We inject  SCSS as <style> into <head> including bootstrap styles during the build process. This way we can skip shipping & referencing of .scss files. Please note: now that there's no need for a .scss references in the front-end, the main.scss reference in the front-end must be removed. BREAKING CHANGE: we skip shipping & referencing of main.scss files. Now that there's no need for a .scss references in the front-end, the main.scss reference in the front-end must be removed. "fix #254", "fix #569"
1 parent a94f4b9 commit afee9ff

File tree

5 files changed

+14
-9
lines changed

5 files changed

+14
-9
lines changed

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@
1111
"typings": "dist/index.d.ts",
1212
"files": [
1313
"dist",
14-
"scss"
14+
"scss",
15+
"!main.scss"
1516
],
1617
"repository": {
1718
"type": "git",

scss/main.scss

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,5 @@
88

99
/* Other CSS Imports */
1010

11-
@import '~react-toastify/dist/ReactToastify.min.css';
1211

13-
/* all scss files in src/components should be imported here */
14-
@import "../src/components/Toaster/toaster.scss";
15-
@import "../src/components/Callout/callout.scss";
12+
/* All component level SCSS files are imported @ component level */

src/components/Callout/Callout.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ import React, { CSSProperties } from 'react'
33

44
import { ColorVariant } from '../../interfaces'
55

6+
import './callout.scss'
7+
68
interface Props {
79
/**
810
* Defines the title of the callout.

src/components/Toaster/index.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ import { ToastContainer, toast, Slide } from 'react-toastify'
44
import { titleWithMessage, titleWithoutMessage } from './components'
55
import { ToastProps, ToasterProps } from './interfaces'
66

7+
import 'react-toastify/dist/ReactToastify.min.css'
8+
import './toaster.scss'
9+
710
export const Toast: any = (
811
type: ToastProps['type'],
912
title: ToastProps['title'],

tsdx.config.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,12 @@ module.exports = {
1212
preset: 'default',
1313
}),
1414
],
15-
inject: false,
16-
// only write out CSS for the first bundle (avoids pointless extra files):
17-
extract: !!options.writeMeta,
18-
modules: true,
15+
// inject SCSS as <style> into <head>
16+
// including bootstrap styles
17+
// to skip shipping & references of .scss files
18+
inject: true,
19+
// to reuse bs4 and other package css styles
20+
modules: false,
1921
}),
2022
)
2123
return config

0 commit comments

Comments
 (0)