https://serverless-stack.com/ logo
#sst
Title
# sst
c

claudioc

03/16/2021, 2:03 PM
@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

Dmitry Pavluk

03/16/2021, 2:27 PM
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

claudioc

03/16/2021, 2:29 PM
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

Dmitry Pavluk

03/16/2021, 4:59 PM
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

Dennis Dang

03/25/2021, 9:32 PM
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.