Skip to content

Commit 1eeb419

Browse files
committed
feat: fixed pkg error
1 parent 0ebad65 commit 1eeb419

File tree

10 files changed

+39
-17
lines changed

10 files changed

+39
-17
lines changed

README.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ Convert external stylesheet to embedded stylesheet, aka document stylesheet.
1414
<link rel="stylesheet" /> => <style>...<style/>
1515
```
1616

17-
Require [mini-css-extract-plugin](https://github.com/webpack-contrib/mini-css-extract-plugin) and [html-webpack-plugin](https://github.com/jantimon/html-webpack-plugin)
17+
Require `rspack.CssExtractRspackPlugin` and `rspack.HtmlRspackPlugin`
1818

1919
## Install
2020
#### NPM
@@ -32,7 +32,7 @@ yarn add html-inline-css-rspack-plugin -D
3232
// const HtmlWebpackPlugin = require('html-webpack-plugin');
3333
// const HTMLInlineCSSWebpackPlugin = require("html-inline-css-rspack-plugin").default;
3434
import { rspack } from '@rspack/core';
35-
import { HTMLInlineRspackPlugin } from 'html-inline-css-webpack-plugin'
35+
import { HTMLInlineRspackPlugin } from 'html-inline-css-rspack-plugin'
3636

3737
module.exports = {
3838
plugins: [
@@ -57,6 +57,10 @@ module.exports = {
5757
}
5858
```
5959

60+
----
61+
62+
> Keep the original config as `html-inline-css-webpack-plugin`.
63+
6064
## Config
6165
```typescript
6266
interface Config {

dist/core/base-plugin.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ export declare class BasePlugin {
66
protected get replaceConfig(): import("../types").ReplaceConfig;
77
protected get styleTagFactory(): StyleTagFactory;
88
constructor(config?: Config);
9-
protected prepare({ assets }: Compilation): void;
9+
protected prepare(compilation: Compilation): void;
1010
protected getCSSStyle({ cssLink, publicPath, }: {
1111
cssLink: string;
1212
publicPath: string;

dist/core/base-plugin.js

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/core/base-plugin.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/index.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1+
export * from './types';
12
export { HTMLInlineRspackPlugin } from './core/rspack';

dist/index.js

Lines changed: 15 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/index.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
{
22
"name": "html-inline-css-rspack-plugin",
3-
"version": "1.11.2",
3+
"version": "1.11.3",
44
"description": "☄️ A rspack plugin for convert external stylesheet to embedded stylesheet, aka document stylesheet",
5-
"main": "./build/index.js",
6-
"types": "./build/index.d.ts",
5+
"main": "./dist/index.js",
6+
"types": "./dist/index.d.ts",
77
"scripts": {
8-
"build": "rm -rf ./build && tsc --project tsconfig.json",
8+
"build": "rm -rf ./dist && tsc --project tsconfig.json",
99
"postpublish": "npm run build",
1010
"test": "ava"
1111
},

src/core/base-plugin.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,15 @@ export class BasePlugin {
2424

2525
constructor(protected readonly config: Config = {}) {}
2626

27-
protected prepare({ assets, deleteAsset }: Compilation) {
28-
Object.keys(assets).forEach((fileName) => {
27+
protected prepare(compilation: Compilation) {
28+
Object.keys(compilation.assets).forEach((fileName) => {
2929
if (isCSS(fileName) && this.isCurrentFileNeedsToBeInlined(fileName)) {
30-
const source = assets[fileName].source();
30+
const source = compilation.assets[fileName].source();
3131
this.cssStyleCache[fileName] = typeof source === 'string' ? source : source.toString();
3232

3333
if (!this.config.leaveCSSFile) {
34-
deleteAsset(fileName);
34+
// https://rspack.dev/zh/api/javascript-api/compilation#deleteasset
35+
compilation.deleteAsset(fileName);
3536
}
3637
}
3738
});

src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1+
export * from './types';
12
export { HTMLInlineRspackPlugin } from './core/rspack';

0 commit comments

Comments
 (0)