Move bundle elements

Signed-off-by: Charles de Dreuille <charles.dedreuille@gmail.com>
This commit is contained in:
Charles de Dreuille
2025-01-15 17:34:44 +00:00
parent e96da19929
commit b7d351fb46
2 changed files with 1 additions and 59 deletions
+1 -3
View File
@@ -27,10 +27,8 @@
"dist"
],
"scripts": {
"build": "yarn build:app && yarn build:css",
"build": "backstage-cli package build",
"build-storybook": "storybook build",
"build:app": "backstage-cli package build",
"build:css": "node scripts/build-css.mjs",
"clean": "backstage-cli package clean",
"lint": "backstage-cli package lint",
"prepack": "backstage-cli package prepack",
-56
View File
@@ -1,56 +0,0 @@
/*
* Copyright 2024 The Backstage Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/* eslint-disable no-restricted-imports */
import { transform, bundle } from 'lightningcss';
import fs from 'fs';
import path from 'path';
/* eslint-enable no-restricted-imports */
// Check if core.css and components.css exist
const cssFiles = ['src/css/core.css', 'src/css/components.css'];
const distDir = 'dist/css';
cssFiles.forEach(file => {
if (!fs.existsSync(file)) {
console.error(`${file} does not exist`);
process.exit(1);
}
});
// Ensure the dist/css directory exists
if (!fs.existsSync(distDir)) {
fs.mkdirSync(distDir, { recursive: true });
}
cssFiles.forEach(file => {
let { code: bundleCode } = bundle({
filename: file,
});
let { code, map } = transform({
filename: `${distDir}/${path.basename(file)}`,
code: bundleCode,
minify: true,
sourceMap: true,
});
fs.writeFileSync(`${distDir}/${path.basename(file)}`, code);
fs.writeFileSync(`${distDir}/${path.basename(file)}.map`, map);
// Clear the content of the original CSS file
fs.writeFileSync(file, '');
});