Fixes bundler setup (#1728)

This commit is contained in:
Mihovil Ilakovac 2024-02-08 12:37:20 +01:00 committed by GitHub
parent dbc2a7f5ea
commit 985825bcd8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 15 additions and 2 deletions

View File

@ -1,8 +1,11 @@
{{={= =}=}}
import esbuild from 'rollup-plugin-esbuild' import esbuild from 'rollup-plugin-esbuild'
export default [ export default [
createBundle('src/server.ts', 'bundle/server.js'), createBundle('src/server.ts', 'bundle/server.js'),
{=# areDbSeedsDefined =}
createBundle('src/dbSeed.ts', 'bundle/dbSeed.js'), createBundle('src/dbSeed.ts', 'bundle/dbSeed.js'),
{=/ areDbSeedsDefined =}
] ]
function createBundle(inputFilePath, outputFilePath) { function createBundle(inputFilePath, outputFilePath) {

View File

@ -50,7 +50,7 @@ import Wasp.Generator.ServerGenerator.Auth.OAuthAuthG (depsRequiredByPassport)
import Wasp.Generator.ServerGenerator.AuthG (genAuth) import Wasp.Generator.ServerGenerator.AuthG (genAuth)
import qualified Wasp.Generator.ServerGenerator.Common as C import qualified Wasp.Generator.ServerGenerator.Common as C
import Wasp.Generator.ServerGenerator.CrudG (genCrud) import Wasp.Generator.ServerGenerator.CrudG (genCrud)
import Wasp.Generator.ServerGenerator.Db.Seed (genDbSeed, getPackageJsonPrismaSeedField) import Wasp.Generator.ServerGenerator.Db.Seed (genDbSeed, getDbSeeds, getPackageJsonPrismaSeedField)
import Wasp.Generator.ServerGenerator.JobGenerator (depsRequiredByJobs, genJobExecutors, genJobs) import Wasp.Generator.ServerGenerator.JobGenerator (depsRequiredByJobs, genJobExecutors, genJobs)
import Wasp.Generator.ServerGenerator.JsImport (extImportToImportJson, getAliasedJsImportStmtAndIdentifier) import Wasp.Generator.ServerGenerator.JsImport (extImportToImportJson, getAliasedJsImportStmtAndIdentifier)
import Wasp.Generator.ServerGenerator.OperationsG (genOperations) import Wasp.Generator.ServerGenerator.OperationsG (genOperations)
@ -66,7 +66,7 @@ genServer spec =
sequence sequence
[ genFileCopy [relfile|README.md|], [ genFileCopy [relfile|README.md|],
genFileCopy [relfile|nodemon.json|], genFileCopy [relfile|nodemon.json|],
genFileCopy [relfile|rollup.config.js|], genRollupConfigJs spec,
genTsConfigJson, genTsConfigJson,
genPackageJson spec (npmDepsForWasp spec), genPackageJson spec (npmDepsForWasp spec),
genNpmrc, genNpmrc,
@ -347,3 +347,12 @@ genOperationsMiddleware spec =
(Just tmplData) (Just tmplData)
where where
tmplData = object ["isAuthEnabled" .= (isAuthEnabled spec :: Bool)] tmplData = object ["isAuthEnabled" .= (isAuthEnabled spec :: Bool)]
genRollupConfigJs :: AppSpec -> Generator FileDraft
genRollupConfigJs spec =
return $
C.mkTmplFdWithData [relfile|rollup.config.js|] (Just tmplData)
where
tmplData = object ["areDbSeedsDefined" .= areDbSeedsDefined]
areDbSeedsDefined = maybe False (not . null) $ getDbSeeds spec

View File

@ -2,6 +2,7 @@ module Wasp.Generator.ServerGenerator.Db.Seed
( genDbSeed, ( genDbSeed,
getPackageJsonPrismaSeedField, getPackageJsonPrismaSeedField,
dbSeedNameEnvVarName, dbSeedNameEnvVarName,
getDbSeeds,
) )
where where