Sha256: f44b30c5cac04df60731b04f8a239bf546e4d1f94e106b5292d014c60356a451

Contents?: true

Size: 813 Bytes

Versions: 2

Compression:

Stored size: 813 Bytes

Contents

const { dirname } = require("path")
const {
  additional_paths: additionalPaths,
  source_path: sourcePath
} = require("../config")

module.exports = {
  test: /\.(bmp|gif|jpe?g|png|tiff|ico|avif|webp|eot|otf|ttf|woff|woff2|svg)$/,
  exclude: /\.(js|mjs|jsx|ts|tsx)$/,
  type: "asset/resource",
  generator: {
    filename: (pathData) => {
      const path = dirname(pathData.filename)
      const stripPaths = [...additionalPaths, sourcePath]

      const selectedStripPath = stripPaths.find((includePath) =>
        path.startsWith(includePath)
      )

      const folders = path
        .replace(`${selectedStripPath}`, "")
        .split("/")
        .filter(Boolean)

      const foldersWithStatic = ["static", ...folders].join("/")
      return `${foldersWithStatic}/[name]-[hash][ext][query]`
    }
  }
}

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
shakapacker-8.0.2 package/rules/file.js
shakapacker-8.0.1 package/rules/file.js