@next-core/build-next-bricks 1.13.0 → 1.13.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
@@ -2,7 +2,9 @@ import type { Compiler, Configuration, RuleSetRule, container } from "webpack";
2
2
 
3
3
  export declare function build(config: BuildNextBricksConfig): Compiler;
4
4
  export declare function getSvgrLoaders(options?: {
5
- /** Set it to true for font icons */
5
+ /** Set it to true for icon font, defaults to false. */
6
+ icon?: boolean | string | number;
7
+ /** Defaults to true when `icon` is truthy, otherwise defaults to false. */
6
8
  convertCurrentColor?: boolean;
7
9
  }): RuleSetRule["use"];
8
10
 
@@ -77,7 +79,7 @@ export interface BuildNextBricksConfig {
77
79
  svgAsReactComponent?: boolean;
78
80
  /** Customize rules for svg, this will take precedence over `svgAsReactComponent` */
79
81
  svgRules?: RuleSetRule[];
80
- /** By default the image assets are named `images/[hash][ext][query]` */
82
+ /** By default the image assets are named `images/[hash][ext]` */
81
83
  imageAssetFilename?: string | ((pathData: any, assetInfo: any) => string);
82
84
  plugins?: Configuration["plugins"];
83
85
  moduleRules?: RuleSetRule[];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@next-core/build-next-bricks",
3
- "version": "1.13.0",
3
+ "version": "1.13.1",
4
4
  "description": "Build next bricks",
5
5
  "homepage": "https://github.com/easyops-cn/next-core/tree/v3/packages/build-next-bricks",
6
6
  "license": "GPL-3.0",
@@ -51,5 +51,5 @@
51
51
  "devDependencies": {
52
52
  "@next-core/brick-manifest": "^0.5.0"
53
53
  },
54
- "gitHead": "06fca79a3a3b63a995d92729cfbed8e312cfdccd"
54
+ "gitHead": "ade903abfe7858ec69518eed83a91c43b54bdd4a"
55
55
  }
package/src/build.js CHANGED
@@ -241,6 +241,8 @@ async function getWebpackConfig(config) {
241
241
  const outputPath = path.join(packageDir, config.outputPath ?? "dist");
242
242
  const chunksDir = isBricks ? "chunks/" : "";
243
243
 
244
+ const imageAssetFilename = config.imageAssetFilename ?? "images/[hash][ext]";
245
+
244
246
  return {
245
247
  entry: config.entry || {
246
248
  main: "./src/index",
@@ -321,7 +323,7 @@ async function getWebpackConfig(config) {
321
323
  ),
322
324
  type: "asset/resource",
323
325
  generator: {
324
- filename: config.imageAssetFilename ?? "images/[hash][ext][query]",
326
+ filename: imageAssetFilename,
325
327
  },
326
328
  },
327
329
  ...(config.svgRules ??
@@ -329,6 +331,29 @@ async function getWebpackConfig(config) {
329
331
  ? [
330
332
  {
331
333
  test: /\.svg$/i,
334
+ type: "asset/resource",
335
+ // Match `xxx.svg?url`
336
+ resourceQuery: /url/,
337
+ generator: {
338
+ filename: imageAssetFilename,
339
+ },
340
+ },
341
+ {
342
+ test: /\.svg$/i,
343
+ // Exclude issuer of js files
344
+ issuer: {
345
+ not: /\.[jt]sx?$/,
346
+ },
347
+ type: "asset/resource",
348
+ generator: {
349
+ filename: imageAssetFilename,
350
+ },
351
+ },
352
+ {
353
+ test: /\.svg$/i,
354
+ issuer: /\.[jt]sx?$/,
355
+ // Exclude `xxx.svg?url`
356
+ resourceQuery: { not: /url/ },
332
357
  use: getSvgrLoaders(),
333
358
  },
334
359
  ]
@@ -10,7 +10,7 @@ export default function getSvgrLoaders(options = {}) {
10
10
  loader: "@svgr/webpack",
11
11
  options: {
12
12
  babel: false,
13
- icon: true,
13
+ icon: options.icon ?? false,
14
14
  svgoConfig: {
15
15
  plugins: [
16
16
  {
@@ -21,7 +21,7 @@ export default function getSvgrLoaders(options = {}) {
21
21
  removeViewBox: false,
22
22
 
23
23
  convertColors: {
24
- currentColor: options.convertCurrentColor ?? false,
24
+ currentColor: options.convertCurrentColor ?? !!options.icon,
25
25
  },
26
26
  },
27
27
  },