Skip to content

Commit

Permalink
Reduce the amount of comments in CSS files compiled from SCSS sources…
Browse files Browse the repository at this point in the history
… by @osd/ui-framework and @osd/ui-shared-deps

Signed-off-by: Miki <miki@amazon.com>
  • Loading branch information
AMoo-Miki committed Jun 30, 2023
1 parent 93f270d commit dfcd784
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 2 deletions.
3 changes: 2 additions & 1 deletion packages/osd-ui-framework/Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
* under the License.
*/

const { strip } = require('comment-stripper');
const sass = require('node-sass');
const postcss = require('postcss');
const postcssConfig = require('@osd/optimizer/postcss.config.js');
Expand Down Expand Up @@ -89,7 +90,7 @@ module.exports = function (grunt) {
}

postcss([postcssConfig])
.process(result.css, { from: src, to: dest })
.process(strip(result.css.toString('utf8')), { from: src, to: dest })
.then((result) => {
grunt.file.write(dest, result.css);

Expand Down
1 change: 1 addition & 0 deletions packages/osd-ui-framework/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
"@elastic/eui": "npm:@opensearch-project/oui@1.2.0",
"@osd/babel-preset": "1.0.0",
"@osd/optimizer": "1.0.0",
"comment-stripper": "^0.0.1",
"grunt": "^1.5.2",
"grunt-babel": "^8.0.0",
"grunt-contrib-clean": "^2.0.0",
Expand Down
3 changes: 3 additions & 0 deletions packages/osd-ui-shared-deps/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
"abortcontroller-polyfill": "^1.4.0",
"angular": "^1.8.2",
"axios": "^0.27.2",
"comment-stripper": "^0.0.1",
"compression-webpack-plugin": "npm:@amoo-miki/compression-webpack-plugin@4.0.1-rc.1",
"core-js": "^3.6.5",
"custom-event-polyfill": "^0.3.0",
Expand All @@ -42,6 +43,8 @@
"@osd/babel-preset": "1.0.0",
"@osd/dev-utils": "1.0.0",
"babel-plugin-transform-react-remove-prop-types": "^0.4.24",
"node-sass": "^8.0.0",
"sass-loader": "^10.4.1",
"css-loader": "^5.2.7",
"del": "^6.1.1",
"loader-utils": "^2.0.4",
Expand Down
4 changes: 4 additions & 0 deletions packages/osd-ui-shared-deps/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,10 @@ exports.getWebpackConfig = ({ dev = false } = {}) => ({
test: /\.css$/,
use: [MiniCssExtractPlugin.loader, 'css-loader'],
},
{
test: /\.scss$/,
use: [MiniCssExtractPlugin.loader, 'css-loader', 'comment-stripper', 'sass-loader'],
},
{
include: [require.resolve('./theme.ts')],
use: [
Expand Down
2 changes: 1 addition & 1 deletion src/core/server/rendering/views/fonts.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ interface FontFace {
}>;
}

const Fonts: FunctionComponent<Props> = ({ url, theme }) => {
export const Fonts: FunctionComponent<Props> = ({ url, theme }) => {
// For new theme
const sourceSans3: FontFace = {
family: 'Source Sans 3',
Expand Down
7 changes: 7 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -6115,6 +6115,13 @@ commander@^5.0.0:
resolved "https://registry.yarnpkg.com/commander/-/commander-5.1.0.tgz#46abbd1652f8e059bddaef99bbdcb2ad9cf179ae"
integrity sha512-P0CysNDQ7rtVw4QIQtm+MRxV66vKFSvlsQvGYXZWR3qFU0jlMKHZZZgw8e+8DSah4UDKMqnknRDQz+xuQXQ/Zg==

comment-stripper@^0.0.1:
version "0.0.1"
resolved "https://registry.yarnpkg.com/comment-stripper/-/comment-stripper-0.0.1.tgz#01759a158df1de081593fa5a2faf22ed7ac410c5"
integrity sha512-7oPLIr3U7tamLi6x2lsxBpyBqHNdEn1fNkz31FBC9nLQl348Gb/3TCdsPDjRGa99oulmGwIZsx5ArxxVvlizWA==
dependencies:
loader-utils "^2.0.0"

commondir@^1.0.1:
version "1.0.1"
resolved "https://registry.yarnpkg.com/commondir/-/commondir-1.0.1.tgz#ddd800da0c66127393cca5950ea968a3aaf1253b"
Expand Down

0 comments on commit dfcd784

Please sign in to comment.