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

fix: Suggested Rollup config corrupts output html #6795

Closed
wants to merge 2 commits into from
Closed
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
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,11 @@ import copy from 'rollup-plugin-copy';
import serve from 'rollup-plugin-serve';
import { terser } from 'rollup-plugin-terser';

const parserOptions = {
sourceType: 'module',
plugins: ['typescript', ['decorators', { decoratorsBeforeExport: true }]],
};

export default {
input: 'src/main.ts',
output: {
Expand All @@ -109,23 +114,22 @@ export default {
},
plugins: [
transformTaggedTemplate({
tagsToProcess: ['html','css'],
parserOptions: {
sourceType: "module",
plugins: [
"typescript",
[
"decorators",
{ decoratorsBeforeExport: true }
]
]
tagsToProcess: ['css'],
transformer: (data) => {
if (/\/\*(?![\s\S]*\*\/)[\s\S]*/g.test(data)) {
throw new Error('Unterminated comment found in CSS tagged template literal');
}
return data.replace(/(?:\s*\/\*(?:[\s\S])+?\*\/\s*)|(?:;)\s+(?=\})|\s+(?=\{)|(?<=:)\s+|\s*([{};,])\s*/g, '$1');
},
parserOptions,
}),
transformTaggedTemplate({
tagsToProcess: ['html'],
transformer: (data) => {
data = data.replace(/\s*([<>])\s*/g, '$1');
return data.replace(/\s{2,}/g, ' ');
},
transformer(data) {
data = data.replace(/\s([{}()>~+=^$:!;])\s/gm, '$1');
data = data.replace(/([",[]])\s+/gm, '$1');
data = data.replace(/\s{2,}/gm, ' ');
return data.trim();
}
parserOptions,
}),
typescript(),
resolve(),
Expand Down Expand Up @@ -257,4 +261,4 @@ Replace the contents of the `<body>` in your `index.html` file with the followin

After saving your `index.html` file, run `npm run build` again, and you should see a card with text and a button.

Congratulations! You're now set up to use FAST, Rollup, and TypeScript. You can import and use more components, build your own components, and when you are ready, build and deploy your website or app to production.
Congratulations! You're now set up to use FAST, Rollup, and TypeScript. You can import and use more components, build your own components, and when you are ready, build and deploy your website or app to production.
Loading