shakapacker 8.4.0 → 9.0.0.beta.2

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.
Files changed (69) hide show
  1. checksums.yaml +4 -4
  2. data/.github/STATUS.md +1 -0
  3. data/.github/workflows/claude-code-review.yml +54 -0
  4. data/.github/workflows/claude.yml +50 -0
  5. data/.github/workflows/dummy.yml +1 -1
  6. data/.github/workflows/generator.yml +4 -14
  7. data/.github/workflows/node.yml +1 -1
  8. data/.rubocop.yml +1 -0
  9. data/CHANGELOG.md +8 -2
  10. data/Gemfile.lock +3 -3
  11. data/README.md +2 -2
  12. data/Rakefile +18 -1
  13. data/docs/css-modules-export-mode.md +288 -0
  14. data/docs/peer-dependencies.md +40 -0
  15. data/docs/rspack.md +190 -0
  16. data/docs/rspack_migration_guide.md +202 -0
  17. data/docs/troubleshooting.md +5 -0
  18. data/docs/using_esbuild_loader.md +3 -3
  19. data/docs/using_swc_loader.md +5 -3
  20. data/lib/install/bin/shakapacker +3 -5
  21. data/lib/install/config/rspack/rspack.config.js +6 -0
  22. data/lib/install/config/shakapacker.yml +6 -2
  23. data/lib/install/package.json +30 -0
  24. data/lib/install/template.rb +12 -2
  25. data/lib/shakapacker/configuration.rb +45 -0
  26. data/lib/shakapacker/dev_server_runner.rb +25 -5
  27. data/lib/shakapacker/manifest.rb +4 -2
  28. data/lib/shakapacker/rspack_runner.rb +19 -0
  29. data/lib/shakapacker/runner.rb +144 -4
  30. data/lib/shakapacker/utils/manager.rb +2 -0
  31. data/lib/shakapacker/version.rb +1 -1
  32. data/lib/shakapacker/version_checker.rb +1 -1
  33. data/lib/shakapacker/webpack_runner.rb +4 -42
  34. data/lib/tasks/shakapacker/install.rake +6 -2
  35. data/package/config.js +24 -0
  36. data/package/environments/base.js +20 -65
  37. data/package/environments/development.js +60 -5
  38. data/package/environments/production.js +29 -51
  39. data/package/environments/test.js +17 -1
  40. data/package/index.d.ts +62 -20
  41. data/package/index.js +4 -2
  42. data/package/optimization/rspack.js +29 -0
  43. data/package/optimization/webpack.js +49 -0
  44. data/package/plugins/rspack.js +88 -0
  45. data/package/plugins/webpack.js +62 -0
  46. data/package/rspack/index.js +57 -0
  47. data/package/rules/babel.js +2 -2
  48. data/package/rules/css.js +1 -1
  49. data/package/rules/esbuild.js +2 -2
  50. data/package/rules/file.js +11 -5
  51. data/package/rules/less.js +1 -1
  52. data/package/rules/raw.js +12 -2
  53. data/package/rules/rspack.js +162 -0
  54. data/package/rules/sass.js +6 -2
  55. data/package/rules/stylus.js +1 -1
  56. data/package/rules/swc.js +2 -2
  57. data/package/utils/debug.js +49 -0
  58. data/package/utils/getStyleRule.js +16 -3
  59. data/package/utils/requireOrError.js +15 -0
  60. data/package/utils/validateDependencies.js +61 -0
  61. data/package/webpackDevServerConfig.js +2 -0
  62. data/package.json +19 -31
  63. data/test/package/environments/base.test.js +1 -1
  64. data/test/package/rules/esbuild.test.js +1 -1
  65. data/test/package/rules/swc.test.js +1 -1
  66. data/test/package/rules/{index.test.js → webpack.test.js} +1 -1
  67. data/yarn.lock +2136 -726
  68. metadata +26 -11
  69. /data/package/rules/{index.js → webpack.js} +0 -0
data/package/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
- declare module 'shakapacker' {
2
- import { Configuration, RuleSetRule } from 'webpack'
3
- import * as https from 'node:https';
1
+ declare module "shakapacker" {
2
+ import { Configuration, RuleSetRule } from "webpack"
3
+ import * as https from "node:https"
4
4
 
5
5
  export interface Config {
6
6
  source_path: string
@@ -14,11 +14,11 @@ declare module 'shakapacker' {
14
14
  shakapacker_precompile: boolean
15
15
  additional_paths: string[]
16
16
  cache_manifest: boolean
17
- webpack_loader: string
17
+ javascript_transpiler: string
18
18
  ensure_consistent_versioning: boolean
19
19
  compiler_strategy: string
20
20
  useContentHash: boolean
21
- compile: boolean,
21
+ compile: boolean
22
22
  outputPath: string
23
23
  publicPath: string
24
24
  publicPathWithoutCDN: string
@@ -33,9 +33,11 @@ declare module 'shakapacker' {
33
33
  runningWebpackDevServer: boolean
34
34
  }
35
35
 
36
- type Header = Array<{ key: string; value: string }> | Record<string, string | string[]>
37
- type ServerType = 'http' | 'https' | 'spdy'
38
- type WebSocketType = 'sockjs' | 'ws'
36
+ type Header =
37
+ | Array<{ key: string; value: string }>
38
+ | Record<string, string | string[]>
39
+ type ServerType = "http" | "https" | "spdy"
40
+ type WebSocketType = "sockjs" | "ws"
39
41
 
40
42
  /**
41
43
  * This has the same keys and behavior as https://webpack.js.org/configuration/dev-server/ except:
@@ -44,45 +46,85 @@ declare module 'shakapacker' {
44
46
  * @see {import('webpack-dev-server').Configuration}
45
47
  */
46
48
  interface DevServerConfig {
47
- allowed_hosts?: 'all' | 'auto' | string | string[]
49
+ allowed_hosts?: "all" | "auto" | string | string[]
48
50
  bonjour?: boolean | Record<string, unknown> // bonjour.BonjourOptions
49
51
  client?: Record<string, unknown> // Client
50
52
  compress?: boolean
51
53
  dev_middleware?: Record<string, unknown> // webpackDevMiddleware.Options
52
54
  headers?: Header | (() => Header)
53
55
  history_api_fallback?: boolean | Record<string, unknown> // HistoryApiFallbackOptions
54
- hmr?: 'only' | boolean
55
- host?: 'local-ip' | 'local-ipv4' | 'local-ipv6' | string
56
+ hmr?: "only" | boolean
57
+ host?: "local-ip" | "local-ipv4" | "local-ipv6" | string
56
58
  http2?: boolean
57
59
  https?: boolean | https.ServerOptions
58
60
  ipc?: boolean | string
59
61
  magic_html?: boolean
60
62
  live_reload?: boolean
61
- open?: boolean | string | string[] | Record<string, unknown> | Record<string, unknown>[]
62
- port?: 'auto' | string | number
63
+ open?:
64
+ | boolean
65
+ | string
66
+ | string[]
67
+ | Record<string, unknown>
68
+ | Record<string, unknown>[]
69
+ port?: "auto" | string | number
63
70
  proxy?: unknown // ProxyConfigMap | ProxyConfigArray
64
71
  setup_exit_signals?: boolean
65
72
  static?: boolean | string | unknown // Static | Array<string | Static>
66
73
  watch_files?: string | string[] | unknown // WatchFiles | Array<WatchFiles | string>
67
- web_socket_server?: string | boolean | WebSocketType | { type?: string | boolean | WebSocketType, options?: Record<string, unknown> }
68
- server?: string | boolean | ServerType | { type?: string | boolean | ServerType, options?: https.ServerOptions }
74
+ web_socket_server?:
75
+ | string
76
+ | boolean
77
+ | WebSocketType
78
+ | {
79
+ type?: string | boolean | WebSocketType
80
+ options?: Record<string, unknown>
81
+ }
82
+ server?:
83
+ | string
84
+ | boolean
85
+ | ServerType
86
+ | { type?: string | boolean | ServerType; options?: https.ServerOptions }
69
87
  [otherWebpackDevServerConfigKey: string]: unknown
70
88
  }
71
89
 
72
90
  export const config: Config
73
91
  export const devServer: DevServerConfig
74
- export function generateWebpackConfig(extraConfig?: Configuration): Configuration
92
+ export function generateWebpackConfig(
93
+ extraConfig?: Configuration
94
+ ): Configuration
75
95
  export const baseConfig: Configuration
76
96
  export const env: Env
77
97
  export const rules: RuleSetRule[]
78
98
  export function moduleExists(packageName: string): boolean
79
- export function canProcess<T = unknown>(rule: string, fn: (modulePath: string) => T): T | null
99
+ export function canProcess<T = unknown>(
100
+ rule: string,
101
+ fn: (modulePath: string) => T
102
+ ): T | null
80
103
  export const inliningCss: boolean
81
- export * from 'webpack-merge'
104
+ export * from "webpack-merge"
82
105
  }
83
106
 
84
- declare module 'shakapacker/package/babel/preset.js' {
85
- import { ConfigAPI, PluginItem, TransformOptions } from '@babel/core'
107
+ declare module "shakapacker/rspack" {
108
+ import type { RspackOptions } from "@rspack/core"
109
+
110
+ export const config: import("shakapacker").Config
111
+ export function generateRspackConfig(
112
+ extraConfig?: RspackOptions
113
+ ): RspackOptions
114
+ export const baseConfig: RspackOptions
115
+ export const env: import("shakapacker").Env
116
+ export const rules: NonNullable<RspackOptions["module"]>["rules"]
117
+ export function moduleExists(packageName: string): boolean
118
+ export function canProcess<T = unknown>(
119
+ rule: string,
120
+ fn: (modulePath: string) => T
121
+ ): T | null
122
+ export const inliningCss: boolean
123
+ export * from "webpack-merge"
124
+ }
125
+
126
+ declare module "shakapacker/package/babel/preset.js" {
127
+ import { ConfigAPI, PluginItem, TransformOptions } from "@babel/core"
86
128
 
87
129
  interface RequiredTransformOptions {
88
130
  plugins: PluginItem[]
data/package/index.js CHANGED
@@ -4,9 +4,11 @@
4
4
  const webpackMerge = require("webpack-merge")
5
5
  const { resolve } = require("path")
6
6
  const { existsSync } = require("fs")
7
- const baseConfig = require("./environments/base")
8
- const rules = require("./rules")
9
7
  const config = require("./config")
8
+ const baseConfig = require("./environments/base")
9
+
10
+ const rulesPath = resolve(__dirname, "rules", `${config.assets_bundler}.js`)
11
+ const rules = require(rulesPath)
10
12
  const devServer = require("./dev_server")
11
13
  const env = require("./env")
12
14
  const { moduleExists, canProcess } = require("./utils/helpers")
@@ -0,0 +1,29 @@
1
+ const { requireOrError } = require("../utils/requireOrError")
2
+ const { error: logError } = require("../utils/debug")
3
+
4
+ const rspack = requireOrError("@rspack/core")
5
+
6
+ const getOptimization = () => {
7
+ // Use Rspack's built-in minification instead of terser-webpack-plugin
8
+ const result = { minimize: true }
9
+ try {
10
+ result.minimizer = [
11
+ new rspack.SwcJsMinimizerRspackPlugin(),
12
+ new rspack.LightningCssMinimizerRspackPlugin()
13
+ ]
14
+ } catch (error) {
15
+ // Log full error with stack trace
16
+ logError(
17
+ `Failed to configure Rspack minimizers: ${error.message}\n${error.stack}`
18
+ )
19
+ // Re-throw the error to properly propagate it
20
+ throw new Error(
21
+ `Could not configure Rspack minimizers: ${error.message}. Please check that @rspack/core is properly installed.`
22
+ )
23
+ }
24
+ return result
25
+ }
26
+
27
+ module.exports = {
28
+ getOptimization
29
+ }
@@ -0,0 +1,49 @@
1
+ const { requireOrError } = require("../utils/requireOrError")
2
+
3
+ const TerserPlugin = requireOrError("terser-webpack-plugin")
4
+ const { moduleExists } = require("../utils/helpers")
5
+
6
+ const tryCssMinimizer = () => {
7
+ if (
8
+ moduleExists("css-loader") &&
9
+ moduleExists("css-minimizer-webpack-plugin")
10
+ ) {
11
+ const CssMinimizerPlugin = requireOrError("css-minimizer-webpack-plugin")
12
+ return new CssMinimizerPlugin()
13
+ }
14
+
15
+ return null
16
+ }
17
+
18
+ const getOptimization = () => {
19
+ return {
20
+ minimizer: [
21
+ tryCssMinimizer(),
22
+ new TerserPlugin({
23
+ parallel: Number.parseInt(process.env.SHAKAPACKER_PARALLEL, 10) || true,
24
+ terserOptions: {
25
+ parse: {
26
+ // Let terser parse ecma 8 code but always output
27
+ // ES5 compliant code for older browsers
28
+ ecma: 8
29
+ },
30
+ compress: {
31
+ ecma: 5,
32
+ warnings: false,
33
+ comparisons: false
34
+ },
35
+ mangle: { safari10: true },
36
+ output: {
37
+ ecma: 5,
38
+ comments: false,
39
+ ascii_only: true
40
+ }
41
+ }
42
+ })
43
+ ].filter(Boolean)
44
+ }
45
+ }
46
+
47
+ module.exports = {
48
+ getOptimization
49
+ }
@@ -0,0 +1,88 @@
1
+ const { requireOrError } = require("../utils/requireOrError")
2
+
3
+ const { RspackManifestPlugin } = requireOrError("rspack-manifest-plugin")
4
+ const rspack = requireOrError("@rspack/core")
5
+ const config = require("../config")
6
+ const { isProduction } = require("../env")
7
+ const { moduleExists } = require("../utils/helpers")
8
+
9
+ const getPlugins = () => {
10
+ const plugins = [
11
+ new rspack.EnvironmentPlugin(process.env),
12
+ new RspackManifestPlugin({
13
+ fileName: config.manifestPath.split("/").pop(), // Get just the filename
14
+ publicPath: config.publicPathWithoutCDN,
15
+ writeToFileEmit: true,
16
+ // rspack-manifest-plugin uses different option names than webpack-assets-manifest
17
+ generate: (seed, files, entrypoints) => {
18
+ const manifest = seed || {}
19
+
20
+ // Add files mapping first
21
+ files.forEach((file) => {
22
+ manifest[file.name] = file.path
23
+ })
24
+
25
+ // Add entrypoints information compatible with Shakapacker expectations
26
+ const entrypointsManifest = {}
27
+ Object.entries(entrypoints).forEach(
28
+ ([entrypointName, entrypointFiles]) => {
29
+ const jsFiles = entrypointFiles
30
+ .filter(
31
+ (file) => file.endsWith(".js") && !file.includes(".hot-update.")
32
+ )
33
+ .map((file) => config.publicPathWithoutCDN + file)
34
+ const cssFiles = entrypointFiles
35
+ .filter(
36
+ (file) =>
37
+ file.endsWith(".css") && !file.includes(".hot-update.")
38
+ )
39
+ .map((file) => config.publicPathWithoutCDN + file)
40
+
41
+ entrypointsManifest[entrypointName] = {
42
+ assets: {
43
+ js: jsFiles,
44
+ css: cssFiles
45
+ }
46
+ }
47
+ }
48
+ )
49
+ manifest.entrypoints = entrypointsManifest
50
+
51
+ return manifest
52
+ }
53
+ })
54
+ ]
55
+
56
+ if (moduleExists("css-loader")) {
57
+ const hash = isProduction || config.useContentHash ? "-[contenthash:8]" : ""
58
+ // Use Rspack's built-in CSS extraction
59
+ const { CssExtractRspackPlugin } = rspack
60
+ plugins.push(
61
+ new CssExtractRspackPlugin({
62
+ filename: `css/[name]${hash}.css`,
63
+ chunkFilename: `css/[id]${hash}.css`,
64
+ // For projects where css ordering has been mitigated through consistent use of scoping or naming conventions,
65
+ // the css order warnings can be disabled by setting the ignoreOrder flag.
66
+ ignoreOrder: config.css_extract_ignore_order_warnings,
67
+ // Force writing CSS files to disk in development for Rails compatibility
68
+ emit: true
69
+ })
70
+ )
71
+ }
72
+
73
+ // Use Rspack's built-in SubresourceIntegrityPlugin
74
+ if (config.integrity.enabled) {
75
+ plugins.push(
76
+ new rspack.SubresourceIntegrityPlugin({
77
+ hashFuncNames: config.integrity.hash_functions,
78
+ enabled: isProduction
79
+ })
80
+ )
81
+ }
82
+
83
+ return plugins
84
+ }
85
+
86
+ module.exports = {
87
+ getPlugins
88
+ }
@@ -0,0 +1,62 @@
1
+ const { requireOrError } = require("../utils/requireOrError")
2
+ // TODO: Change to `const { WebpackAssetsManifest }` when dropping 'webpack-assets-manifest < 6.0.0' (Node >=20.10.0) support
3
+ const WebpackAssetsManifest = requireOrError("webpack-assets-manifest")
4
+ const webpack = requireOrError("webpack")
5
+ const config = require("../config")
6
+ const { isProduction } = require("../env")
7
+ const { moduleExists } = require("../utils/helpers")
8
+
9
+ const getPlugins = () => {
10
+ // TODO: Remove WebpackAssetsManifestConstructor workaround when dropping 'webpack-assets-manifest < 6.0.0' (Node >=20.10.0) support
11
+ const WebpackAssetsManifestConstructor =
12
+ "WebpackAssetsManifest" in WebpackAssetsManifest
13
+ ? WebpackAssetsManifest.WebpackAssetsManifest
14
+ : WebpackAssetsManifest
15
+ const plugins = [
16
+ new webpack.EnvironmentPlugin(process.env),
17
+ new WebpackAssetsManifestConstructor({
18
+ entrypoints: true,
19
+ writeToDisk: true,
20
+ output: config.manifestPath,
21
+ entrypointsUseAssets: true,
22
+ publicPath: config.publicPathWithoutCDN,
23
+ integrity: config.integrity.enabled,
24
+ integrityHashes: config.integrity.hash_functions
25
+ })
26
+ ]
27
+
28
+ if (moduleExists("css-loader") && moduleExists("mini-css-extract-plugin")) {
29
+ const hash = isProduction || config.useContentHash ? "-[contenthash:8]" : ""
30
+ const MiniCssExtractPlugin = requireOrError("mini-css-extract-plugin")
31
+ plugins.push(
32
+ new MiniCssExtractPlugin({
33
+ filename: `css/[name]${hash}.css`,
34
+ chunkFilename: `css/[id]${hash}.css`,
35
+ // For projects where css ordering has been mitigated through consistent use of scoping or naming conventions,
36
+ // the css order warnings can be disabled by setting the ignoreOrder flag.
37
+ ignoreOrder: config.css_extract_ignore_order_warnings
38
+ })
39
+ )
40
+ }
41
+
42
+ if (
43
+ config.integrity.enabled &&
44
+ moduleExists("webpack-subresource-integrity")
45
+ ) {
46
+ const SubresourceIntegrityPlugin = requireOrError(
47
+ "webpack-subresource-integrity"
48
+ )
49
+ plugins.push(
50
+ new SubresourceIntegrityPlugin({
51
+ hashFuncNames: config.integrity.hash_functions,
52
+ enabled: isProduction
53
+ })
54
+ )
55
+ }
56
+
57
+ return plugins
58
+ }
59
+
60
+ module.exports = {
61
+ getPlugins
62
+ }
@@ -0,0 +1,57 @@
1
+ /* eslint global-require: 0 */
2
+ /* eslint import/no-dynamic-require: 0 */
3
+
4
+ const webpackMerge = require("webpack-merge")
5
+ const { resolve } = require("path")
6
+ const { existsSync } = require("fs")
7
+ const config = require("../config")
8
+ const baseConfig = require("../environments/base")
9
+
10
+ const rulesPath = resolve(__dirname, "../rules", "rspack.js")
11
+ const rules = require(rulesPath)
12
+ const devServer = require("../dev_server")
13
+ const env = require("../env")
14
+ const { moduleExists, canProcess } = require("../utils/helpers")
15
+ const inliningCss = require("../utils/inliningCss")
16
+ const { getPlugins } = require("../plugins/rspack")
17
+ const { getOptimization } = require("../optimization/rspack")
18
+ const { validateRspackDependencies } = require("../utils/validateDependencies")
19
+
20
+ const generateRspackConfig = (extraConfig = {}, ...extraArgs) => {
21
+ // Validate required dependencies first
22
+ validateRspackDependencies()
23
+ if (extraArgs.length > 0) {
24
+ throw new Error(
25
+ "Only one extra config may be passed here - use webpack-merge to merge configs before passing them to Shakapacker"
26
+ )
27
+ }
28
+
29
+ const { nodeEnv } = env
30
+ const path = resolve(__dirname, "../environments", `${nodeEnv}.js`)
31
+ const environmentConfig = existsSync(path) ? require(path) : baseConfig
32
+
33
+ // Create base rspack config
34
+ const rspackConfig = {
35
+ ...environmentConfig,
36
+ module: {
37
+ rules
38
+ },
39
+ plugins: getPlugins(),
40
+ optimization: getOptimization()
41
+ }
42
+
43
+ return webpackMerge.merge({}, rspackConfig, extraConfig)
44
+ }
45
+
46
+ module.exports = {
47
+ config, // shakapacker.yml
48
+ devServer,
49
+ generateRspackConfig,
50
+ baseConfig,
51
+ env,
52
+ rules,
53
+ moduleExists,
54
+ canProcess,
55
+ inliningCss,
56
+ ...webpackMerge
57
+ }
@@ -1,9 +1,9 @@
1
1
  const { loaderMatches } = require("../utils/helpers")
2
- const { webpack_loader: webpackLoader } = require("../config")
2
+ const { javascript_transpiler: javascriptTranspiler } = require("../config")
3
3
  const { isProduction } = require("../env")
4
4
  const jscommon = require("./jscommon")
5
5
 
6
- module.exports = loaderMatches(webpackLoader, "babel", () => ({
6
+ module.exports = loaderMatches(javascriptTranspiler, "babel", () => ({
7
7
  test: /\.(js|jsx|mjs|ts|tsx|coffee)?(\.erb)?$/,
8
8
  ...jscommon,
9
9
  use: [
data/package/rules/css.js CHANGED
@@ -1,3 +1,3 @@
1
- const getStyleRule = require("../utils/getStyleRule")
1
+ const { getStyleRule } = require("../utils/getStyleRule")
2
2
 
3
3
  module.exports = getStyleRule(/\.(css)$/i)
@@ -1,9 +1,9 @@
1
1
  const { loaderMatches } = require("../utils/helpers")
2
2
  const { getEsbuildLoaderConfig } = require("../esbuild")
3
- const { webpack_loader: webpackLoader } = require("../config")
3
+ const { javascript_transpiler: javascriptTranspiler } = require("../config")
4
4
  const jscommon = require("./jscommon")
5
5
 
6
- module.exports = loaderMatches(webpackLoader, "esbuild", () => ({
6
+ module.exports = loaderMatches(javascriptTranspiler, "esbuild", () => ({
7
7
  test: /\.(ts|tsx|js|jsx|mjs|coffee)?(\.erb)?$/,
8
8
  ...jscommon,
9
9
  use: ({ resource }) => getEsbuildLoaderConfig(resource)
@@ -1,4 +1,4 @@
1
- const { dirname } = require("path")
1
+ const { dirname, sep, normalize } = require("path")
2
2
  const {
3
3
  additional_paths: additionalPaths,
4
4
  source_path: sourcePath
@@ -10,16 +10,22 @@ module.exports = {
10
10
  type: "asset/resource",
11
11
  generator: {
12
12
  filename: (pathData) => {
13
- const path = dirname(pathData.filename)
14
- const stripPaths = [...additionalPaths, sourcePath]
13
+ const path = normalize(dirname(pathData.filename))
14
+ const stripPaths = [...additionalPaths, sourcePath].map((p) =>
15
+ normalize(p)
16
+ )
15
17
 
16
18
  const selectedStripPath = stripPaths.find((includePath) =>
17
19
  path.startsWith(includePath)
18
20
  )
19
21
 
22
+ if (!selectedStripPath) {
23
+ return `static/[name]-[hash][ext][query]`
24
+ }
25
+
20
26
  const folders = path
21
- .replace(`${selectedStripPath}`, "")
22
- .split("/")
27
+ .replace(selectedStripPath, "")
28
+ .split(sep)
23
29
  .filter(Boolean)
24
30
 
25
31
  const foldersWithStatic = ["static", ...folders].join("/")
@@ -1,6 +1,6 @@
1
1
  const path = require("path")
2
2
  const { canProcess } = require("../utils/helpers")
3
- const getStyleRule = require("../utils/getStyleRule")
3
+ const { getStyleRule } = require("../utils/getStyleRule")
4
4
 
5
5
  const {
6
6
  additional_paths: paths,
data/package/rules/raw.js CHANGED
@@ -1,5 +1,15 @@
1
- module.exports = {
1
+ const config = require("../config")
2
+
3
+ const rspackRawConfig = () => ({
4
+ resourceQuery: /raw/,
5
+ type: "asset/source"
6
+ })
7
+
8
+ const webpackRawConfig = () => ({
2
9
  test: /\.html$/,
3
10
  exclude: /\.(js|mjs|jsx|ts|tsx)$/,
4
11
  type: "asset/source"
5
- }
12
+ })
13
+
14
+ module.exports =
15
+ config.assets_bundler === "rspack" ? rspackRawConfig() : webpackRawConfig()