-
Notifications
You must be signed in to change notification settings - Fork 271
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: transform css files to es6 modules (#306)
- bundling without an additional setup for importing css files used to be broken - all css files are now distributed as es6 modules that export a single string - ui5-togglebutton used to override some css variables defined in the ui5-button
- Loading branch information
Showing
8 changed files
with
29 additions
and
29 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 |
---|---|---|
@@ -1,11 +1,13 @@ | ||
const postcssNesting = require('postcss-nesting'); | ||
const postcssAddFallback = require('../../lib/postcss-add-fallback/index.js'); | ||
const postcssCSStoESM = require('../../lib/postcss-css-to-esm/index.js'); | ||
const cssnano = require('cssnano'); | ||
|
||
module.exports = { | ||
plugins: [ | ||
postcssNesting(), | ||
postcssAddFallback({importFrom: "./dist/themes-next/sap_fiori_3/parameters-bundle.css"}), | ||
postcssAddFallback({importFrom: "./dist/css/themes-next/sap_fiori_3/parameters-bundle.css"}), | ||
cssnano(), | ||
postcssCSStoESM(), | ||
] | ||
}; |
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 @@ | ||
const postcss = require('postcss'); | ||
const fs = require('fs'); | ||
const path = require('path'); | ||
const mkdirp = require('mkdirp'); | ||
|
||
module.exports = postcss.plugin('add css to esm transform plugin', function (opts) { | ||
opts = opts || {}; | ||
|
||
return function (root) { | ||
const css = JSON.stringify(root.toString()); | ||
const targetFile = root.source.input.from.replace("/src/", "/dist/"); | ||
|
||
mkdirp.sync(path.dirname(targetFile)); | ||
|
||
const filePath = `${targetFile}.js`; | ||
|
||
fs.writeFileSync(filePath, `export default ${css}`); | ||
} | ||
}); |
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
4 changes: 0 additions & 4 deletions
4
packages/main/src/themes-next/base/ToggleButton-parameters.css
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
2 changes: 0 additions & 2 deletions
2
packages/main/src/themes-next/sap_fiori_3/ToggleButton-parameters.css
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,8 +1,6 @@ | ||
@import "../base/ToggleButton-parameters.css"; | ||
|
||
:root { | ||
--_ui5_button_base_min_width: 2.25rem; | ||
--_ui5_button_base_height: 2.25rem; | ||
--_ui5_toggle_button_pressed_negative_hover: var(--sapUiButtonRejectActiveBackgroundLighten5); | ||
--_ui5_toggle_button_pressed_positive_hover: var(--sapUiButtonAcceptActiveBackgroundLighten5); | ||
} |