aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Keller <tjkeller.xyz>2025-05-23 14:30:44 -0500
committerTim Keller <tjkeller.xyz>2025-05-23 14:30:44 -0500
commit470883b4b836447692ac3ea5d2b4fc50cbdfecba (patch)
treeb9548fb32225b5733a7becbcc0eaa42b2770b88d
parente01a5e79337f31e656ed6d87c3cc168a06f0f27a (diff)
downloadmaterial-svg-atlas-plugin-webpack-470883b4b836447692ac3ea5d2b4fc50cbdfecba.tar.xz
material-svg-atlas-plugin-webpack-470883b4b836447692ac3ea5d2b4fc50cbdfecba.zip
create directories for file
-rw-r--r--material-symbols-plugin.js4
-rw-r--r--utils.js5
2 files changed, 7 insertions, 2 deletions
diff --git a/material-symbols-plugin.js b/material-symbols-plugin.js
index b161883..48b1123 100644
--- a/material-symbols-plugin.js
+++ b/material-symbols-plugin.js
@@ -3,7 +3,7 @@ const path = require("path")
const crypto = require("crypto")
const axios = require("axios")
const { Compilation } = require("webpack")
-const { generateAtlasViewsFromReferences } = require("./utils.js")
+const { generateAtlasViewsFromReferences, createDirectoriesForFile } = require("./utils.js")
class MaterialSymbolsDownloader {
@@ -126,6 +126,8 @@ class MaterialSymbolsAtlasPlugin {
await cache.storePromise(cacheKey, null, atlas)
}
+ createDirectoriesForFile(this.filename)
+
compilation.emitAsset(
this.filename,
new compiler.webpack.sources.RawSource(atlas)
diff --git a/utils.js b/utils.js
index 0e372ae..8284755 100644
--- a/utils.js
+++ b/utils.js
@@ -74,5 +74,8 @@ async function generateAtlasViewsFromReferences(refs, symbolId) {
return generateAtlasViews(result.symbol.sprite.contents.toString(), symbolId)
}
+function createDirectoriesForFile(filePath) {
+ fs.mkdirSync(path.dirname(filePath), { recursive: true })
+}
-module.exports = { generateAtlasViews, generateAtlasViewsFromReferences }
+module.exports = { generateAtlasViews, generateAtlasViewsFromReferences, createDirectoriesForFile }