Skip to content
Draft
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
50 changes: 41 additions & 9 deletions packages/cherry-markdown/build/rollup.styles.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import scss from 'rollup-plugin-scss';
import * as dartSass from 'sass';
import path from 'node:path';
// baseConfig not used in styles config

const IS_PRODUCTION = process.env.NODE_ENV === 'production';
Expand All @@ -33,6 +33,40 @@ const createCleanupPlugin = () => ({
},
});

const createSassAssetPlugin = ({ input, fileName, style = 'expanded', watch }) => ({
name: `sass-asset:${fileName}`,
transform(code, id) {
if (path.resolve(id) !== path.resolve(input)) {
return null;
}

return {
code: 'export default undefined;',
map: { mappings: '' },
};
},
buildStart() {
if (watch) {
const files = Array.isArray(watch) ? watch : [watch];
files.forEach((file) => this.addWatchFile(file));
}
Comment on lines +48 to +52
Copy link

Copilot AI Apr 5, 2026

Choose a reason for hiding this comment

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

createSassAssetPlugin only registers the optional watch list, but it doesn’t add watch entries for the actual Sass dependency graph (partials loaded via @use/@forward/meta.load-css). In rollup --watch, edits to imported SCSS may not trigger a rebuild unless they’re manually listed. Consider collecting dependencies from the Sass compile result (e.g., loaded URLs/files) and calling this.addWatchFile for each of them (or expanding the provided watch to all .scss files).

Copilot uses AI. Check for mistakes.
},
async generateBundle() {
const entryFile = path.resolve(input);
const result = await dartSass.compileAsync(entryFile, {
loadPaths: ['node_modules', process.cwd()],
style,
charset: false,
});

this.emitFile({
type: 'asset',
fileName,
source: result.css,
});
},
});

const createStyleConfigs = ({ input, cssBaseName, outputBaseName, watch }) => {
const configs = [
{
Expand All @@ -41,11 +75,10 @@ const createStyleConfigs = ({ input, cssBaseName, outputBaseName, watch }) => {
file: `dist/${outputBaseName}.styles.js`,
},
plugins: [
scss({
createSassAssetPlugin({
input,
fileName: `${cssBaseName}.css`,
failOnError: true,
sass: dartSass,
...(watch ? { watch } : {}),
watch,
}),
createCleanupPlugin(),
],
Expand All @@ -59,11 +92,10 @@ const createStyleConfigs = ({ input, cssBaseName, outputBaseName, watch }) => {
file: `dist/${outputBaseName}.styles.min.js`,
},
plugins: [
scss({
createSassAssetPlugin({
input,
fileName: `${cssBaseName}.min.css`,
failOnError: true,
sass: dartSass,
outputStyle: 'compressed',
style: 'compressed',
}),
createCleanupPlugin(),
],
Expand Down
14 changes: 7 additions & 7 deletions packages/cherry-markdown/src/sass/bubble_formula.scss
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
width: 120px;
flex-shrink: 0;
padding: 8px;
border-right: 1px solid var(--base-border-color);
border-right: 1px solid var(--color-border-default);
position: relative;

.cherry-formula-main-tabs {
Expand All @@ -28,7 +28,7 @@
cursor: pointer;
font-size: 14px;
font-weight: 500;
color: var(--base-font-color);
color: var(--color-text-primary);
user-select: none;
transition: background-color 0.2s ease, color 0.2s ease;

Expand Down Expand Up @@ -58,7 +58,7 @@
white-space: nowrap;

a {
color: var(--primary-color);
color: var(--color-brand-primary);
text-decoration: none;

&:hover {
Expand Down Expand Up @@ -99,7 +99,7 @@
border-radius: 16px;
cursor: pointer;
font-size: 13px;
color: var(--base-font-color);
color: var(--color-text-primary);
user-select: none;
transition: background-color 0.2s ease, color 0.2s ease;

Expand Down Expand Up @@ -139,10 +139,10 @@
.cherry-formula-grid-group-title {
font-size: 14px;
font-weight: 600;
color: var(--base-font-color);
color: var(--color-text-primary);
margin-bottom: 12px;
padding-bottom: 8px;
border-bottom: 1px solid var(--base-border-color);
border-bottom: 1px solid var(--color-border-default);
}

.cherry-formula-grid-items {
Expand All @@ -159,7 +159,7 @@
border-radius: 8px;
cursor: pointer;
transition: background-color 0.2s ease, border-color 0.2s ease;
background-color: var(--base-editor-bg);
background-color: var(--color-bg-canvas);

&:hover {
background-color: var(--dropdown-item-hover-bg);
Expand Down
Loading
Loading