Skip to content

Commit

Permalink
chore(builder): simplify assets rule (#4701)
Browse files Browse the repository at this point in the history
* chore(builder): simply assets rule

* chore: spell

* fix: snapshot
  • Loading branch information
9aoy authored Sep 21, 2023
1 parent bb97082 commit 3448e82
Show file tree
Hide file tree
Showing 8 changed files with 122 additions and 539 deletions.
7 changes: 7 additions & 0 deletions .changeset/big-snakes-kick.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
'@modern-js/builder': patch
---

chore(builder): simplify assets rule

chore(builder): 简化 assets 规则
Original file line number Diff line number Diff line change
Expand Up @@ -85,13 +85,8 @@ exports[`applyDefaultPlugins > should apply default plugins correctly 1`] = `
"generator": {
"filename": "static/font/[name].[contenthash:8][ext]",
},
"parser": {
"dataUrlCondition": {
"maxSize": 0,
},
},
"resourceQuery": /\\(__inline=false\\|url\\)/,
"type": "asset",
"type": "asset/resource",
},
{
"resourceQuery": /inline/,
Expand All @@ -117,13 +112,8 @@ exports[`applyDefaultPlugins > should apply default plugins correctly 1`] = `
"generator": {
"filename": "static/image/[name].[contenthash:8][ext]",
},
"parser": {
"dataUrlCondition": {
"maxSize": 0,
},
},
"resourceQuery": /\\(__inline=false\\|url\\)/,
"type": "asset",
"type": "asset/resource",
},
{
"resourceQuery": /inline/,
Expand All @@ -149,13 +139,8 @@ exports[`applyDefaultPlugins > should apply default plugins correctly 1`] = `
"generator": {
"filename": "static/media/[name].[contenthash:8][ext]",
},
"parser": {
"dataUrlCondition": {
"maxSize": 0,
},
},
"resourceQuery": /\\(__inline=false\\|url\\)/,
"type": "asset",
"type": "asset/resource",
},
{
"resourceQuery": /inline/,
Expand Down Expand Up @@ -187,13 +172,8 @@ exports[`applyDefaultPlugins > should apply default plugins correctly 1`] = `
/\\\\\\.\\(ts\\|mts\\|cts\\|tsx\\)\\$/,
],
},
"parser": {
"dataUrlCondition": {
"maxSize": 0,
},
},
"resourceQuery": /\\(__inline=false\\|url\\)/,
"type": "asset",
"type": "asset/resource",
},
{
"issuer": {
Expand Down Expand Up @@ -224,29 +204,14 @@ exports[`applyDefaultPlugins > should apply default plugins correctly 1`] = `
},
{
"resourceQuery": /inline/,
"type": "javascript/auto",
"use": [
{
"loader": "<WORKSPACE>/packages/builder/builder-shared/compiled/url-loader",
"options": {
"limit": Infinity,
"name": "static/svg/[name].[contenthash:8].svg",
},
},
],
"type": "asset/inline",
},
{
"generator": {
"filename": "static/svg/[name].[contenthash:8].svg",
},
"resourceQuery": /url/,
"type": "javascript/auto",
"use": [
{
"loader": "<WORKSPACE>/packages/builder/builder-shared/compiled/url-loader",
"options": {
"limit": false,
"name": "static/svg/[name].[contenthash:8].svg",
},
},
],
"type": "asset/resource",
},
{
"type": "javascript/auto",
Expand Down Expand Up @@ -837,13 +802,8 @@ exports[`applyDefaultPlugins > should apply default plugins correctly when prod
"generator": {
"filename": "static/font/[name].[contenthash:8][ext]",
},
"parser": {
"dataUrlCondition": {
"maxSize": 0,
},
},
"resourceQuery": /\\(__inline=false\\|url\\)/,
"type": "asset",
"type": "asset/resource",
},
{
"resourceQuery": /inline/,
Expand All @@ -869,13 +829,8 @@ exports[`applyDefaultPlugins > should apply default plugins correctly when prod
"generator": {
"filename": "static/image/[name].[contenthash:8][ext]",
},
"parser": {
"dataUrlCondition": {
"maxSize": 0,
},
},
"resourceQuery": /\\(__inline=false\\|url\\)/,
"type": "asset",
"type": "asset/resource",
},
{
"resourceQuery": /inline/,
Expand All @@ -901,13 +856,8 @@ exports[`applyDefaultPlugins > should apply default plugins correctly when prod
"generator": {
"filename": "static/media/[name].[contenthash:8][ext]",
},
"parser": {
"dataUrlCondition": {
"maxSize": 0,
},
},
"resourceQuery": /\\(__inline=false\\|url\\)/,
"type": "asset",
"type": "asset/resource",
},
{
"resourceQuery": /inline/,
Expand Down Expand Up @@ -939,13 +889,8 @@ exports[`applyDefaultPlugins > should apply default plugins correctly when prod
/\\\\\\.\\(ts\\|mts\\|cts\\|tsx\\)\\$/,
],
},
"parser": {
"dataUrlCondition": {
"maxSize": 0,
},
},
"resourceQuery": /\\(__inline=false\\|url\\)/,
"type": "asset",
"type": "asset/resource",
},
{
"issuer": {
Expand Down Expand Up @@ -976,29 +921,14 @@ exports[`applyDefaultPlugins > should apply default plugins correctly when prod
},
{
"resourceQuery": /inline/,
"type": "javascript/auto",
"use": [
{
"loader": "<WORKSPACE>/packages/builder/builder-shared/compiled/url-loader",
"options": {
"limit": Infinity,
"name": "static/svg/[name].[contenthash:8].svg",
},
},
],
"type": "asset/inline",
},
{
"generator": {
"filename": "static/svg/[name].[contenthash:8].svg",
},
"resourceQuery": /url/,
"type": "javascript/auto",
"use": [
{
"loader": "<WORKSPACE>/packages/builder/builder-shared/compiled/url-loader",
"options": {
"limit": false,
"name": "static/svg/[name].[contenthash:8].svg",
},
},
],
"type": "asset/resource",
},
{
"type": "javascript/auto",
Expand Down Expand Up @@ -1641,13 +1571,8 @@ exports[`applyDefaultPlugins > should apply default plugins correctyly when targ
"generator": {
"filename": "static/font/[name].[contenthash:8][ext]",
},
"parser": {
"dataUrlCondition": {
"maxSize": 0,
},
},
"resourceQuery": /\\(__inline=false\\|url\\)/,
"type": "asset",
"type": "asset/resource",
},
{
"resourceQuery": /inline/,
Expand All @@ -1673,13 +1598,8 @@ exports[`applyDefaultPlugins > should apply default plugins correctyly when targ
"generator": {
"filename": "static/image/[name].[contenthash:8][ext]",
},
"parser": {
"dataUrlCondition": {
"maxSize": 0,
},
},
"resourceQuery": /\\(__inline=false\\|url\\)/,
"type": "asset",
"type": "asset/resource",
},
{
"resourceQuery": /inline/,
Expand All @@ -1705,13 +1625,8 @@ exports[`applyDefaultPlugins > should apply default plugins correctyly when targ
"generator": {
"filename": "static/media/[name].[contenthash:8][ext]",
},
"parser": {
"dataUrlCondition": {
"maxSize": 0,
},
},
"resourceQuery": /\\(__inline=false\\|url\\)/,
"type": "asset",
"type": "asset/resource",
},
{
"resourceQuery": /inline/,
Expand Down Expand Up @@ -1743,13 +1658,8 @@ exports[`applyDefaultPlugins > should apply default plugins correctyly when targ
/\\\\\\.\\(ts\\|mts\\|cts\\|tsx\\)\\$/,
],
},
"parser": {
"dataUrlCondition": {
"maxSize": 0,
},
},
"resourceQuery": /\\(__inline=false\\|url\\)/,
"type": "asset",
"type": "asset/resource",
},
{
"issuer": {
Expand Down Expand Up @@ -1780,29 +1690,14 @@ exports[`applyDefaultPlugins > should apply default plugins correctyly when targ
},
{
"resourceQuery": /inline/,
"type": "javascript/auto",
"use": [
{
"loader": "<WORKSPACE>/packages/builder/builder-shared/compiled/url-loader",
"options": {
"limit": Infinity,
"name": "static/svg/[name].[contenthash:8].svg",
},
},
],
"type": "asset/inline",
},
{
"generator": {
"filename": "static/svg/[name].[contenthash:8].svg",
},
"resourceQuery": /url/,
"type": "javascript/auto",
"use": [
{
"loader": "<WORKSPACE>/packages/builder/builder-shared/compiled/url-loader",
"options": {
"limit": false,
"name": "static/svg/[name].[contenthash:8].svg",
},
},
],
"type": "asset/resource",
},
{
"type": "javascript/auto",
Expand Down Expand Up @@ -2147,13 +2042,8 @@ exports[`tools.rspack > should match snapshot 1`] = `
"generator": {
"filename": "static/font/[name].[contenthash:8][ext]",
},
"parser": {
"dataUrlCondition": {
"maxSize": 0,
},
},
"resourceQuery": /\\(__inline=false\\|url\\)/,
"type": "asset",
"type": "asset/resource",
},
{
"resourceQuery": /inline/,
Expand All @@ -2179,13 +2069,8 @@ exports[`tools.rspack > should match snapshot 1`] = `
"generator": {
"filename": "static/image/[name].[contenthash:8][ext]",
},
"parser": {
"dataUrlCondition": {
"maxSize": 0,
},
},
"resourceQuery": /\\(__inline=false\\|url\\)/,
"type": "asset",
"type": "asset/resource",
},
{
"resourceQuery": /inline/,
Expand All @@ -2211,13 +2096,8 @@ exports[`tools.rspack > should match snapshot 1`] = `
"generator": {
"filename": "static/media/[name].[contenthash:8][ext]",
},
"parser": {
"dataUrlCondition": {
"maxSize": 0,
},
},
"resourceQuery": /\\(__inline=false\\|url\\)/,
"type": "asset",
"type": "asset/resource",
},
{
"resourceQuery": /inline/,
Expand Down Expand Up @@ -2249,13 +2129,8 @@ exports[`tools.rspack > should match snapshot 1`] = `
/\\\\\\.\\(ts\\|mts\\|cts\\|tsx\\)\\$/,
],
},
"parser": {
"dataUrlCondition": {
"maxSize": 0,
},
},
"resourceQuery": /\\(__inline=false\\|url\\)/,
"type": "asset",
"type": "asset/resource",
},
{
"issuer": {
Expand Down Expand Up @@ -2286,29 +2161,14 @@ exports[`tools.rspack > should match snapshot 1`] = `
},
{
"resourceQuery": /inline/,
"type": "javascript/auto",
"use": [
{
"loader": "<WORKSPACE>/packages/builder/builder-shared/compiled/url-loader",
"options": {
"limit": Infinity,
"name": "static/svg/[name].[contenthash:8].svg",
},
},
],
"type": "asset/inline",
},
{
"generator": {
"filename": "static/svg/[name].[contenthash:8].svg",
},
"resourceQuery": /url/,
"type": "javascript/auto",
"use": [
{
"loader": "<WORKSPACE>/packages/builder/builder-shared/compiled/url-loader",
"options": {
"limit": false,
"name": "static/svg/[name].[contenthash:8].svg",
},
},
],
"type": "asset/resource",
},
{
"type": "javascript/auto",
Expand Down
Loading

0 comments on commit 3448e82

Please sign in to comment.