Created
February 18, 2019 12:39
-
-
Save chcepe/fe187d2a65d6cbd780e475c6f47ec781 to your computer and use it in GitHub Desktop.
Script to compress Next.js build folder with web.config
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const stat = require("fs").statSync; | |
const AdmZip = require("adm-zip"); | |
newArchive(`deploy.zip`, [ | |
".next", | |
"static", | |
"next.config.js", | |
"package-lock.json", | |
"package.json", | |
"server.js", | |
"web.config" | |
]); | |
function newArchive(zipFileName, pathNames) { | |
const zip = new AdmZip(); | |
pathNames.forEach(path => { | |
const p = stat(path); | |
if (p.isFile()) { | |
zip.addLocalFile(path); | |
} else if (p.isDirectory()) { | |
zip.addLocalFolder(path, path); | |
} | |
}); | |
zip.writeZip(zipFileName); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"name": "create-next-example-app", | |
"scripts": { | |
"dev": "next", | |
"build": "next build && node deploy.js", | |
"start": "next start", | |
"export": "next export" | |
}, | |
"dependencies": { | |
"adm-zip": "^0.4.13", | |
"express": "^4.16.4", | |
"next": "^8.0.0", | |
"react": "16.7.0", | |
"react-dom": "16.7.0" | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0"?> | |
<configuration> | |
<system.web> | |
<compilation batch="false" /> | |
</system.web> | |
<system.webServer> | |
<handlers> | |
<add name="iisnode" path="server.js" verb="*" modules="iisnode" /> | |
</handlers> | |
<rewrite> | |
<rules> | |
<rule name="myapp"> | |
<match url="/*" /> | |
<action type="Rewrite" url="server.js" /> | |
</rule> | |
</rules> | |
</rewrite> | |
</system.webServer> | |
</configuration> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment