From 69fb75a48e531937845b806855c2ece4a8786c83 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Abd=C3=B3n=20Rodr=C3=ADguez=20Davila?= Date: Thu, 3 Nov 2022 07:25:24 -0400 Subject: [PATCH] Fix the build step (#180) --- .changeset/new-turkeys-doubt.md | 5 +++ package.json | 3 +- rollup-ui-shell-bundle.config.js | 37 ------------------- rollup.config.js | 62 +++++++++++++++++++++----------- 4 files changed, 47 insertions(+), 60 deletions(-) create mode 100644 .changeset/new-turkeys-doubt.md delete mode 100644 rollup-ui-shell-bundle.config.js diff --git a/.changeset/new-turkeys-doubt.md b/.changeset/new-turkeys-doubt.md new file mode 100644 index 0000000..0099ddb --- /dev/null +++ b/.changeset/new-turkeys-doubt.md @@ -0,0 +1,5 @@ +--- +'@qiskit/web-components': patch +--- + +Fix the build step diff --git a/package.json b/package.json index 7773192..c41399c 100644 --- a/package.json +++ b/package.json @@ -15,7 +15,6 @@ "scripts": { "analyze-lit": "lit-analyzer components/**/*.ts --strict", "build": "tsc && rollup --config rollup.config.js", - "build:ui-shell-bundle": "tsc && rollup --config rollup-ui-shell-bundle.config.js", "dev": "npm run storybook:start", "format": "npm-run-all format:*", "format:eslint": "npm run lint:eslint -- --fix", @@ -24,7 +23,7 @@ "lint": "npm-run-all --parallel lint:*", "lint:eslint": "eslint '**/*.{js,ts}' --ignore-path .gitignore", "lint:stylelint": "stylelint 'components/**/*.{scss,ts}' --ignore-path .gitignore", - "prepack": "npm run build && npm run build:ui-shell-bundle", + "prepack": "npm run build", "prepare": "npx simple-git-hooks", "release": "changeset publish", "start": "npm run storybook:start", diff --git a/rollup-ui-shell-bundle.config.js b/rollup-ui-shell-bundle.config.js deleted file mode 100644 index df28867..0000000 --- a/rollup-ui-shell-bundle.config.js +++ /dev/null @@ -1,37 +0,0 @@ -/** - * Copyright (c) IBM, Corp. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ - -import { nodeResolve } from '@rollup/plugin-node-resolve'; -import terser from '@rollup/plugin-terser'; -import litcss from 'rollup-plugin-lit-css'; -import sass from 'sass'; - -const transformSassToCss = (data, { filePath }) => - sass - .renderSync({ - data, - file: filePath, - includePaths: [new URL('node_modules/', import.meta.url).pathname], - }) - .css.toString(); - -export default { - input: `components/ui-shell/index.js`, - plugins: [ - litcss({ - include: '**/*.scss', - transform: transformSassToCss, - uglify: true, - }), - nodeResolve(), - terser(), - ], - output: { - file: 'experimental-bundled-ui-shell.js', - format: 'esm', - }, -}; diff --git a/rollup.config.js b/rollup.config.js index 780e7fd..c2707f8 100644 --- a/rollup.config.js +++ b/rollup.config.js @@ -7,6 +7,8 @@ import { readdirSync } from 'fs'; +import { nodeResolve } from '@rollup/plugin-node-resolve'; +import terser from '@rollup/plugin-terser'; import litcss from 'rollup-plugin-lit-css'; import sass from 'sass'; @@ -27,25 +29,43 @@ const componentPaths = readdirSync('components/', { withFileTypes: true }) const iconsDirIndex = componentPaths.indexOf('icons'); componentPaths.splice(iconsDirIndex, 1); -export default componentPaths.map((component) => ({ - input: `components/${component}/index.js`, - plugins: [ - litcss({ - include: '**/*.scss', - transform: transformSassToCss, - uglify: true, - }), - ], - output: { - dir: `components/${component}/`, - format: 'esm', - sourcemap: true, +export default [ + ...componentPaths.map((component) => ({ + input: `components/${component}/index.js`, + plugins: [ + litcss({ + include: '**/*.scss', + transform: transformSassToCss, + uglify: true, + }), + ], + output: { + dir: `components/${component}/`, + format: 'esm', + sourcemap: true, + }, + external: [ + 'tslib', + 'lit', + /^lit\/.*/, + /^carbon-web-components\/.*/, + /^@carbon\/.*/, + ], + })), + { + input: `components/ui-shell/index.js`, + plugins: [ + litcss({ + include: '**/*.scss', + transform: transformSassToCss, + uglify: true, + }), + nodeResolve(), + terser(), + ], + output: { + file: 'experimental-bundled-ui-shell.js', + format: 'esm', + }, }, - external: [ - 'tslib', - 'lit', - /^lit\/.*/, - /^carbon-web-components\/.*/, - /^@carbon\/.*/, - ], -})); +];