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

chore(masthead-v2-alpha): cherry pick template literal minification #11504

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* @license
*
* Copyright IBM Corp. 2020, 2022
* Copyright IBM Corp. 2020, 2024
*
* This source code is licensed under the Apache-2.0 license found in the
* LICENSE file in the root directory of this source tree.
Expand Down Expand Up @@ -38,22 +38,6 @@ function scripts() {
// `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',
{
modules: {
'lit-html': ['html'],
'lit-element': ['html'],
},
htmlMinifier: {
collapseWhitespace: true,
conservativeCollapse: true,
removeComments: true,
caseSensitive: true,
minifyCSS: true,
},
},
],
babelPluginResourceJSPaths,
],
})
Expand Down
1 change: 1 addition & 0 deletions packages/carbon-web-components/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,7 @@
"replace-ext": "^2.0.0",
"resize-observer-polyfill": "^1.5.0",
"rollup": "^2.55.1",
"rollup-plugin-minify-html-literals": "^1.2.6",
"rollup-plugin-multi-input": "^1.3.1",
"rtlcss": "^3.0.0",
"sass": "~1.62.0",
Expand Down
41 changes: 17 additions & 24 deletions packages/carbon-web-components/tools/get-rollup-config.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* @license
*
* Copyright IBM Corp. 2020, 2022
* Copyright IBM Corp. 2020, 2024
*
* This source code is licensed under the Apache-2.0 license found in the
* LICENSE file in the root directory of this source tree.
Expand All @@ -20,6 +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;

const carbonIcons = require('./rollup-plugin-icons');
const fixHostPseudo = require('./postcss-fix-host-pseudo');
Expand Down Expand Up @@ -129,6 +131,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 @@ -142,29 +155,9 @@ function getRollupConfig({
'@babel/plugin-proposal-decorators',
{ decoratorsBeforeExport: true },
],
'@babel/plugin-proposal-nullish-coalescing-operator',
['@babel/plugin-proposal-object-rest-spread', { useBuiltIns: true }],
'@babel/plugin-proposal-optional-chaining',
...(mode === 'development'
? []
: [
[
'template-html-minifier',
{
modules: {
'lit-html': ['html'],
'lit-element': ['html'],
},
htmlMinifier: {
collapseWhitespace: true,
conservativeCollapse: true,
removeComments: true,
caseSensitive: true,
minifyCSS: true,
},
},
],
]),
'@babel/plugin-transform-nullish-coalescing-operator',
['@babel/plugin-transform-object-rest-spread', { useBuiltIns: true }],
'@babel/plugin-transform-optional-chaining',
],
}),
litSCSS({
Expand Down
1 change: 1 addition & 0 deletions packages/web-components/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,7 @@
"rollup": "^2.55.1",
"rollup-plugin-analyzer": "^4.0.0",
"rollup-plugin-inject-process-env": "^1.3.1",
"rollup-plugin-minify-html-literals": "^1.2.6",
"rollup-plugin-multi-input": "^1.3.1",
"rollup-plugin-sizes": "^1.0.4",
"rtlcss": "^3.0.0",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* @license
*
* Copyright IBM Corp. 2020, 2023
* Copyright IBM Corp. 2020, 2024
*
* This source code is licensed under the Apache-2.0 license found in the
* LICENSE file in the root directory of this source tree.
Expand Down Expand Up @@ -858,9 +858,7 @@ class DDSTableOfContents extends HostListenerMixin(
<div class="${prefix}--tableofcontents__desktop-container">
<div
class="${prefix}--tableofcontents__desktop"
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
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
<div class="bx--tableofcontents__desktop-container">
<div
class="bx--tableofcontents__desktop"
style="left: -0px"
style="inset-inline-start: -0px"
>
<div class="bx--sub-content-left">
</div>
Expand Down Expand Up @@ -84,7 +84,7 @@
<div class="bx--tableofcontents__desktop-container">
<div
class="bx--tableofcontents__desktop"
style="left: -0px"
style="inset-inline-start: -0px"
>
<div class="bx--sub-content-left">
</div>
Expand Down Expand Up @@ -133,7 +133,7 @@
<div class="bx--tableofcontents__desktop-container">
<div
class="bx--tableofcontents__desktop"
style="left: -0px"
style="inset-inline-start: -0px"
>
<div class="bx--sub-content-left">
</div>
Expand Down
41 changes: 17 additions & 24 deletions packages/web-components/tools/get-rollup-config.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* @license
*
* Copyright IBM Corp. 2020, 2023
* Copyright IBM Corp. 2020, 2024
*
* This source code is licensed under the Apache-2.0 license found in the
* LICENSE file in the root directory of this source tree.
Expand All @@ -24,6 +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;

const ibmdotcomIcon = require('./rollup-plugin-ibmdotcom-icon');
const litSCSS = require('./rollup-plugin-lit-scss');
Expand Down Expand Up @@ -164,6 +166,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 @@ -187,29 +200,9 @@ function getRollupConfig({
'@babel/plugin-proposal-decorators',
{ decoratorsBeforeExport: true },
],
'@babel/plugin-proposal-nullish-coalescing-operator',
['@babel/plugin-proposal-object-rest-spread', { useBuiltIns: true }],
'@babel/plugin-proposal-optional-chaining',
...(mode === 'development'
? []
: [
[
'template-html-minifier',
{
modules: {
'lit-html': ['html'],
'lit-element': ['html'],
},
htmlMinifier: {
collapseWhitespace: true,
conservativeCollapse: true,
removeComments: true,
caseSensitive: true,
minifyCSS: true,
},
},
],
]),
'@babel/plugin-transform-nullish-coalescing-operator',
['@babel/plugin-transform-object-rest-spread', { useBuiltIns: true }],
'@babel/plugin-transform-optional-chaining',
],
}),
// We are using `carbon-web-components` code merely as the source of inheritance,
Expand Down
Loading
Loading