Skip to content

Commit

Permalink
Reduce the amount of comments in compiled CSS
Browse files Browse the repository at this point in the history
Signed-off-by: Miki <miki@amazon.com>
  • Loading branch information
AMoo-Miki committed Aug 1, 2023
1 parent a52e95c commit 3568810
Show file tree
Hide file tree
Showing 8 changed files with 36 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
- Enable theme-switching via Advanced Settings to preview the Next theme ([#4475](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/4475))
- Optimize `augment-vis` saved obj searching by adding arg to saved obj client ([#4595](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/4595))
- Add resource ID filtering in fetch `augment-vis` obj queries ([#4608](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/4608))
- Reduce the amount of comments in compiled CSS ([#4648](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/4648))
- [Discover] Update styles to compatible with OUI `next` theme ([#4644](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/4644))

### 🐛 Bug Fixes
Expand Down
1 change: 1 addition & 0 deletions packages/osd-optimizer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
"@types/watchpack": "^1.1.6",
"@types/webpack": "^4.41.31",
"babel-loader": "^8.2.3",
"comment-stripper": "^0.0.1",
"css-loader": "^5.2.7",
"file-loader": "^6.2.0",
"loader-utils": "^2.0.4",
Expand Down
7 changes: 7 additions & 0 deletions packages/osd-optimizer/src/worker/webpack.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,12 @@ export function getWebpackConfig(bundle: Bundle, bundleRefs: BundleRefs, worker:
sourceMap: !worker.dist,
},
},
{
loader: 'comment-stripper',
options: {
language: 'css',
},
},
],
},
{
Expand Down Expand Up @@ -164,6 +170,7 @@ export function getWebpackConfig(bundle: Bundle, bundleRefs: BundleRefs, worker:
},
},
},
'comment-stripper',
{
loader: 'sass-loader',
options: {
Expand Down
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 @@ -91,7 +92,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.3.0-alpha.2",
"@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 @@ -42,9 +42,12 @@
"@osd/babel-preset": "1.0.0",
"@osd/dev-utils": "1.0.0",
"babel-plugin-transform-react-remove-prop-types": "^0.4.24",
"comment-stripper": "^0.0.1",
"css-loader": "^5.2.7",
"del": "^6.1.1",
"loader-utils": "^2.0.4",
"node-sass": "^8.0.0",
"sass-loader": "^10.4.1",
"val-loader": "^2.1.2",
"webpack": "npm:@amoo-miki/webpack@4.46.0-rc.2"
}
Expand Down
15 changes: 14 additions & 1 deletion packages/osd-ui-shared-deps/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,20 @@ exports.getWebpackConfig = ({ dev = false } = {}) => ({
},
{
test: /\.css$/,
use: [MiniCssExtractPlugin.loader, 'css-loader'],
use: [
MiniCssExtractPlugin.loader,
'css-loader',
{
loader: 'comment-stripper',
options: {
language: 'css',
},
},
],
},
{
test: /\.scss$/,
use: [MiniCssExtractPlugin.loader, 'css-loader', 'comment-stripper', 'sass-loader'],
},
{
include: [require.resolve('./theme.ts')],
Expand Down
7 changes: 7 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -6100,6 +6100,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 3568810

Please sign in to comment.