# Import / bundle static files (like json or txt) at build time

**URL:** <https://forum.dfinity.org/t/import-bundle-static-files-like-json-or-txt-at-build-time/8442>\
**Category:** Developers\
**Created:** [November 8, 2021, 3:08pm UTC](https://forum.dfinity.org/t/import-bundle-static-files-like-json-or-txt-at-build-time/8442 "2021-11-08T15:08:53Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![peterparker](https://avatars.discourse-cdn.com/v4/letter/p/b9bd4f/32.png) [@peterparker](https://forum.dfinity.org/u/peterparker)\
**Post date:** [November 8, 2021, 3:08pm UTC](https://forum.dfinity.org/t/import-bundle-static-files-like-json-or-txt-at-build-time/8442/1 "2021-11-08T15:08:53Z")

</div>

Is it possible in Motoko with dfx to import a static file and include its content in the wasm output bundle?

For example, I would like to have a `.json` or `.txt` file next to my Motoko code, use it and bundle it at build time.

Side note: at build time because I am looking to use these static data in actor canister that are generated on the fly upon calls from my web app

---

<div class="post-metadata">

**Author:** ![claudio](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/claudio/32/322_2.png) [@claudio](https://forum.dfinity.org/u/claudio)\
**Post date:** [November 8, 2021, 3:28pm UTC](https://forum.dfinity.org/t/import-bundle-static-files-like-json-or-txt-at-build-time/8442/2 "2021-11-08T15:28:15Z")

</div>

Not at the moment. You’re best bet is to include it as a Text or Blob constant, or write a preprocessor that takes the .txt/.json file and turns it into a Motoko declaration. Something like:

foo.txt:

```auto
hello
world

```

becomes:

Resources.mo

```auto
module {
  public let foo = "hello\n world";
}

```

---

<div class="post-metadata">

**Author:** ![peterparker](https://avatars.discourse-cdn.com/v4/letter/p/b9bd4f/32.png) [@peterparker](https://forum.dfinity.org/u/peterparker)\
**Post date:** [November 8, 2021, 3:36pm UTC](https://forum.dfinity.org/t/import-bundle-static-files-like-json-or-txt-at-build-time/8442/3 "2021-11-08T15:36:53Z")

</div>

Thanks for the quick feedback. I’ll probably follow the preprocessor way then.

---

<div class="post-metadata">

**Author:** ![peterparker](https://avatars.discourse-cdn.com/v4/letter/p/b9bd4f/32.png) [@peterparker](https://forum.dfinity.org/u/peterparker)\
**Post date:** [November 26, 2021, 3:05pm UTC](https://forum.dfinity.org/t/import-bundle-static-files-like-json-or-txt-at-build-time/8442/4 "2021-11-26T15:05:07Z")

</div>

I wrote a NodeJS script regarding this subject which I ultimately might not use but, if it can be useful to someone one day, here you go → [Gist](https://gist.github.com/peterpeterparker/e4bbf657e17edf1b57bf39b07651b5a9)

Note: it generates the variable as a Blob / Nat8 array to avoid text conflicts, like double quotes within double quotes
