Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(minify shadowroots): add rollup-plugin-minify-html-literals #11207

Open
wants to merge 22 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
d25d64e
chore(add-rollup-plugin): just adding the plugins
marcelojcs Dec 7, 2023
608cb8b
feat(rollup=plugin): Set up get-rollup
marcelojcs Dec 7, 2023
7396fa8
feat(add rollup-plugin) added gulp packages
marcelojcs Dec 7, 2023
3e81fbb
config(gulp files): config script.js
marcelojcs Dec 7, 2023
4740315
Merge branch 'main' into feat/minfy-html-v2
andy-blum Dec 11, 2023
ee43d94
fix(rollup-plugon): fixing a typo
marcelojcs Dec 12, 2023
e99bcf1
Merge branch 'feat/minfy-html-v2' of github.com:marcelojcs/carbon-for…
marcelojcs Dec 12, 2023
a4994c0
fix(table-of-contents): fix minify bug
marcelojcs Dec 13, 2023
cde2ce9
Merge branch 'main' into feat/minfy-html-v2
marcelojcs Dec 15, 2023
8aaa07c
feat(minify-html-literals): run yarn format
marcelojcs Dec 15, 2023
4750d5b
feat(minify-html-literals): Fixing ci check
marcelojcs Dec 18, 2023
64c5cf8
Merge branch 'main' into feat/minfy-html-v2
marcelojcs Dec 18, 2023
45a2d9f
Merge branch 'main' into feat/minfy-html-v2
m4olivei Dec 18, 2023
ded039c
feat(minify-html-literals): removing blank line from package.json
marcelojcs Dec 19, 2023
a1a45a3
Merge branch 'main' into feat/minfy-html-v2
marcelojcs Jan 2, 2024
f9ceab9
Merge branch 'main' into feat/minfy-html-v2
marcelojcs Jan 3, 2024
d809f53
Merge branch 'main' into feat/minfy-html-v2
marcelojcs Jan 11, 2024
8f2914b
Merge branch 'main' into feat/minfy-html-v2
kennylam Jan 11, 2024
c81cd41
Merge branch 'main' into feat/minfy-html-v2
kennylam Jan 16, 2024
84a4027
Merge branch 'main' into feat/minfy-html-v2
kennylam Jan 19, 2024
c02faf3
Merge branch 'main' into feat/minfy-html-v2
marcelojcs Jan 22, 2024
1edf753
Merge branch 'main' into feat/minfy-html-v2
marcelojcs Jan 22, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const filter = require('gulp-filter');
const gulp = require('gulp');
const sourcemaps = require('gulp-sourcemaps');
const stripComments = require('strip-comments');

const minifyHTMLLiterals = require('gulp-minify-html-literals');
const babelPluginResourceJSPaths = require('../../../tools/babel-plugin-resource-js-paths');
const config = require('../../config');

Expand All @@ -32,28 +32,23 @@ function scripts() {
`!${config.srcDir}/index-with-polyfills.ts`,
])
.pipe(sourcemaps.init())
.pipe(minifyHTMLLiterals({
failOnError: true,
options: {
minifyOptions: {
caseSensitive: true,
collapseInlineTagWhitespace: true,
collapseWhitespace: true,
removeComments: true
},
},
}))
.pipe(
babel({
presets: ['@babel/preset-modules'],
// `version` field ensures `@babel/plugin-transform-runtime` is applied to newer helpers like decorator
plugins: [
['@babel/plugin-transform-runtime', { useESModules: true, version: '7.8.0' }],
[
'template-html-minifier', // TODO: verify this is actually needed, doesn't seem to be doing anything
{
modules: {
'lit-html': ['html'],
'lit-element': ['html'],
},
htmlMinifier: {
collapseWhitespace: true,
conservativeCollapse: true,
removeComments: true,
caseSensitive: true,
minifyCSS: true,
},
},
],
babelPluginResourceJSPaths,
],
})
Expand Down
4 changes: 3 additions & 1 deletion packages/carbon-web-components/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,10 @@
"@babel/runtime": "^7.16.3",
"@carbon/styles": "1.47.0",
"flatpickr": "4.6.1",
"gulp-minify-html-literals": "^1.1.22",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This package doesn't seem to exist. Is this the one you meant to include?

"lit": "^2.7.6",
"lodash-es": "^4.17.21"
"lodash-es": "^4.17.21",
"rollup-plugin-minify-html-literals": "^1.2.6"
},
"devDependencies": {
"@babel/core": "~7.12.0",
Expand Down
34 changes: 13 additions & 21 deletions packages/carbon-web-components/tools/get-rollup-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ const { nodeResolve } = require('@rollup/plugin-node-resolve');
const rtlcss = require('rtlcss');
const { promisify } = require('util');
const { terser } = require('rollup-plugin-terser');

const minifyHTMLLiterals =
require('rollup-plugin-minify-html-literals').default;
m4olivei marked this conversation as resolved.
Show resolved Hide resolved
const carbonIcons = require('./rollup-plugin-icons');
const fixHostPseudo = require('./postcss-fix-host-pseudo');
const license = require('./rollup-plugin-license');
Expand Down Expand Up @@ -129,6 +130,17 @@ function getRollupConfig({
include: [/node_modules/],
sourceMap: true,
}),
minifyHTMLLiterals({
failOnError: true,
options: {
minifyOptions: {
caseSensitive: true,
collapseInlineTagWhitespace: true,
collapseWhitespace: true,
removeComments: true,
},
},
}),
carbonIcons(),
babel.babel({
babelHelpers: 'runtime',
Expand All @@ -145,26 +157,6 @@ function getRollupConfig({
'@babel/plugin-transform-nullish-coalescing-operator',
['@babel/plugin-transform-object-rest-spread', { useBuiltIns: true }],
'@babel/plugin-transform-optional-chaining',
...(mode === 'development'
? []
: [
[
'template-html-minifier', // TODO: verify this is actually needed, doesn't seem to be doing anything
{
modules: {
'lit-html': ['html'],
'lit-element': ['html'],
},
htmlMinifier: {
collapseWhitespace: true,
conservativeCollapse: true,
removeComments: true,
caseSensitive: true,
minifyCSS: true,
},
},
],
]),
],
}),
litSCSS({
Expand Down
13 changes: 12 additions & 1 deletion packages/web-components/gulp-tasks/build/modules/scripts.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const sourcemaps = require('gulp-sourcemaps');
const babel = require('gulp-babel');
const stripComments = require('strip-comments');
const babelPluginResourceJSPaths = require('../../../tools/babel-plugin-resource-js-paths');

const minifyHTMLLiterals = require('gulp-minify-html-literals');
const config = require('../../config');

/**
Expand All @@ -34,6 +34,17 @@ function scripts() {
`!${config.srcDir}/**/ibmdotcom-web-components-*.ts`,
])
.pipe(sourcemaps.init())
.pipe(minifyHTMLLiterals({
failOnError: true,
options: {
minifyOptions: {
caseSensitive: true,
collapseInlineTagWhitespace: true,
collapseWhitespace: true,
removeComments: true
},
},
}))
.pipe(
babel({
presets: ['@babel/preset-modules', '@babel/preset-env'],
Expand Down
2 changes: 2 additions & 0 deletions packages/web-components/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -97,12 +97,14 @@
"@carbon/motion": "11.16.1",
"@carbon/styles": "1.47.0",
"@carbon/telemetry": "0.1.0",
"gulp-minify-html-literals": "^1.1.22",
"@carbon/web-components": "2.2.0-rc.0",
"lit": "^2.7.6",
"lodash-es": "^4.17.21",
"redux": "^4.0.0",
"redux-logger": "^3.0.0",
"redux-thunk": "^2.3.0",
"rollup-plugin-minify-html-literals": "^1.2.6",
"wicg-inert": "^3.1.2",
"window-or-global": "^1.0.1"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -796,9 +796,7 @@ class C4DTableOfContents extends MediaQueryMixin(
<div class="${prefix}--tableofcontents-container">
<div
class="${prefix}--tableofcontents"
style="${pageIsRTL
? 'right'
: 'left'}: -${currentScrollPosition}px">
style="inset-inline-start: -${currentScrollPosition}px">
${pageIsRTL
? html` <div class="${prefix}--sub-content-right"></div> `
: html` <div class="${prefix}--sub-content-left"></div> `}
Expand Down
34 changes: 13 additions & 21 deletions packages/web-components/tools/get-rollup-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ const replace = require('@rollup/plugin-replace');
const { terser } = require('rollup-plugin-terser');
const multiInput = require('rollup-plugin-multi-input').default;
const injectProcessEnv = require('rollup-plugin-inject-process-env');

const minifyHTMLLiterals =
require('rollup-plugin-minify-html-literals').default;
m4olivei marked this conversation as resolved.
Show resolved Hide resolved
const ibmdotcomIcon = require('./rollup-plugin-ibmdotcom-icon');
const litSCSS = require('./rollup-plugin-lit-scss');
const fixHostPseudo = require('./postcss-fix-host-pseudo');
Expand Down Expand Up @@ -157,6 +158,17 @@ function getRollupConfig({
include: [/node_modules/],
sourceMap: true,
}),
minifyHTMLLiterals({
failOnError: true,
options: {
minifyOptions: {
caseSensitive: true,
collapseInlineTagWhitespace: true,
collapseWhitespace: true,
removeComments: true,
},
},
}),
ibmdotcomIcon(),
injectProcessEnv(
{
Expand All @@ -183,26 +195,6 @@ function getRollupConfig({
'@babel/plugin-transform-nullish-coalescing-operator',
['@babel/plugin-transform-object-rest-spread', { useBuiltIns: true }],
'@babel/plugin-transform-optional-chaining',
...(mode === 'development'
? []
: [
[
'template-html-minifier', // TODO: verify this is actually needed, doesn't seem to be doing anything
{
modules: {
'lit-html': ['html'],
'lit-element': ['html'],
},
htmlMinifier: {
collapseWhitespace: true,
conservativeCollapse: true,
removeComments: true,
caseSensitive: true,
minifyCSS: true,
},
},
],
]),
],
}),
// We are using `carbon-web-components` code merely as the source of inheritance,
Expand Down
Loading
Loading