<@U01R7RRL8SZ> from 0.9.18 it is possible to use a...
# sst
c
@Dmitry Pavluk from 0.9.18 it is possible to use all the predefined esbuild loaders; would it work for you to do something like
Copy code
import sql from './sql/seed.sql'

// Do something with the sql (which is just a string)
That’s a pretty easy setup (I can share it)
d
I tried that as well - I just got the name of the file, not the contents
I got around it by just hardcoding the path to those files, shouldn't need to use them outside of local dev anyway
c
mmh OK, but it works for me (I am bundling HTML, CSS with that method). You just need to :
Copy code
return new sst.Api(this, 'Api', {
      defaultFunctionProps: {
        bundle: {
          loader: {
            '.html': 'text',
            '.css': 'text'
          }
        },
      },
      routes: { ...
d
Well I need SQL files to load, haven't been able to get the
file
esBuild loader to grab them.
I don't truly need esBuild to load them. I just need them in the
.build
folder to be referenceable. They're loaded via
fs.readFileSync
. The
copyFiles
option would be a lot more conducive to our use case.
d
In the end, it was as simple as
copyFiles: [{ from: "src/db", to: "/src/db" }]
The file structure of the built files vs the development files are a few layers different. But I used a variable flag to change the path resolution accordingly.