Skip to content

Commit 4415733

Browse files
authored
Add example of using npm ci
1 parent 249fa77 commit 4415733

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

examples/build-package/main.tf

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,29 @@ module "package_with_commands_and_patterns" {
244244
]
245245
}
246246

247+
# Some use cases might require the production packages are deployed while maintaining local node_modules folder
248+
# This example saves the node_modules folder by moving it to an ignored directory
249+
# After the zip file is created with production node_modules, the dev node_modules folder is restored
250+
module "package_with_commands_and_patterns" {
251+
source = "../../"
252+
253+
runtime = "nodejs18.x"
254+
source_path = [
255+
{
256+
path = "./app"
257+
commands = [
258+
"mv ./node_modules ./node_modules_temp",
259+
"npm ci --production",
260+
":zip",
261+
"rm -rf node_modules",
262+
"mv ./node_modules_temp ./node_modules",
263+
]
264+
patterns = [
265+
"!node_modules_temp/.*"
266+
]
267+
}
268+
]
269+
}
247270
# Create zip-archive with various sources and patterns.
248271
# Note, that it is possible to write comments in patterns.
249272
module "package_with_patterns" {

0 commit comments

Comments
 (0)