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: do not remove origin output css when config cssChunkNames #5490

Merged
merged 3 commits into from
Sep 26, 2022
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
4 changes: 4 additions & 0 deletions packages/plugin-fusion/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## 0.1.23

- [fix] return sourceMap with custom loader of `unicodeLoader`

## 0.1.22

- [fix] remove alias config of `~` for vite
Expand Down
2 changes: 1 addition & 1 deletion packages/plugin-fusion/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "build-plugin-fusion",
"version": "0.1.22",
"version": "0.1.23",
"description": "plugin for build scripts while use fusion component",
"main": "lib/index.js",
"scripts": {
Expand Down
10 changes: 6 additions & 4 deletions packages/plugin-fusion/src/webpackLoaders/unicodeLoader.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
const convertCharStr2CSS = require('../utils/convertCharStr');

module.exports = (source) => {
return source.replace(/content:\s*(?:'|")([\u0080-\uffff])(?:'|")/g, (str, $1) => {
function unicodeLoader(source, sourceMap) {
const callback = this.async();
callback(null, source.replace(/content:\s*(?:'|")([\u0080-\uffff])(?:'|")/g, (str, $1) => {
return `content: "${convertCharStr2CSS($1)}"`;
});
};
}), sourceMap) ;
}
module.exports = unicodeLoader;
4 changes: 4 additions & 0 deletions packages/vite-service/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# CHANGELOG

## 2.1.5

- [fix] do not remove origin css when config `cssChunkNames`.

## 2.1.4

- [fix] avoid top-level warning of esbuild.
Expand Down
2 changes: 1 addition & 1 deletion packages/vite-service/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@builder/vite-service",
"version": "2.1.4",
"version": "2.1.5",
"description": "vite implementation",
"author": "ice-admin@alibaba-inc.com",
"homepage": "",
Expand Down
2 changes: 1 addition & 1 deletion packages/vite-service/src/plugins/cssChunk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ export const cssChunk = (chunkName: ChunkName): Plugin => {
const cssName = parseCssName(cssChunkName, cssIndex);
const renamedCss = formatPath(path.join(cssDir, cssName));
if (cssLink !== renamedCss) {
fse.moveSync(sourceCss, path.join(outputDir, cssDir, cssName));
fse.writeFileSync(path.join(outputDir, cssDir, cssName), fse.readFileSync(sourceCss, 'utf-8'));
// replace css link
htmlContent = htmlContent.replace(/<link[\s\S]*href=["']([^'"]*)["'][^>]*>/g, (str, matched) => {
return matched === `${base}${cssLink}` ? str.replace(matched, `${base}${renamedCss}`) : str;
Expand Down