@next-core/build-next-bricks 1.0.2 → 1.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.d.ts CHANGED
@@ -66,6 +66,8 @@ export interface BuildNextBricksConfig {
66
66
  mode?: "development" | "production";
67
67
  entry?: Record<string, string>;
68
68
  extractCss?: boolean;
69
+ svgAsAsset?: boolean;
70
+ imageAssetFilename?: string | ((pathData: any, assetInfo: any) => string);
69
71
  plugins?: Configuration["plugins"];
70
72
  moduleRules?: RuleSetRule[];
71
73
  exposes?: ConstructorParameters<typeof container.ModuleFederationPlugin>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@next-core/build-next-bricks",
3
- "version": "1.0.2",
3
+ "version": "1.1.1",
4
4
  "description": "Build next bricks",
5
5
  "homepage": "https://github.com/easyops-cn/next-core/tree/master/packages/build-next-bricks",
6
6
  "license": "GPL-3.0",
@@ -46,5 +46,5 @@
46
46
  "typescript": "^5.0.2",
47
47
  "webpack": "^5.76.2"
48
48
  },
49
- "gitHead": "ffd8b31a5d99db5af3b4ec7675ff2d6541eb1338"
49
+ "gitHead": "f4639c59925a6f007fdf03630bcb9a9b0163cd8b"
50
50
  }
package/src/build.js CHANGED
@@ -244,7 +244,7 @@ export default async function build(config) {
244
244
  test: /\.svg$/i,
245
245
  issuer(input) {
246
246
  // The issuer is null (or an empty string) for dynamic import
247
- return !input || /\.[jt]sx?$/.test(input);
247
+ return !config.svgAsAsset && (!input || /\.[jt]sx?$/.test(input));
248
248
  },
249
249
  use: [
250
250
  {
@@ -278,6 +278,22 @@ export default async function build(config) {
278
278
  },
279
279
  ],
280
280
  },
281
+ {
282
+ // Images
283
+ test: /\.(png|svg|jpg|jpeg|gif)$/i,
284
+ type: "asset/resource",
285
+ generator: {
286
+ filename: config.imageAssetFilename ?? "images/[hash][ext][query]",
287
+ },
288
+ },
289
+ {
290
+ // Fonts
291
+ test: /\.(woff|woff2|eot|ttf|otf)$/i,
292
+ type: "asset/resource",
293
+ generator: {
294
+ filename: "fonts/[hash][ext][query]",
295
+ },
296
+ },
281
297
  ...(config.moduleRules || []),
282
298
  ],
283
299
  },
package/src/scanBricks.js CHANGED
@@ -248,12 +248,14 @@ export default async function scanBricks(packageDir) {
248
248
  }
249
249
  } else if (
250
250
  callee.type === "Identifier" &&
251
- callee.name === "wrapBrick" &&
251
+ (callee.name === "wrapBrick" || callee.name === "unwrapProvider") &&
252
252
  args.length >= 1
253
253
  ) {
254
254
  const { type, value: brickName } = args[0];
255
255
  if (type !== "StringLiteral") {
256
- throw new Error("Please call `wrapBrick` only with literal string");
256
+ throw new Error(
257
+ `Please call \`${callee.name}\` only with literal string`
258
+ );
257
259
  }
258
260
  const bricks = usingWrappedBricks.get(filePath);
259
261
  if (bricks) {