Skip to content

Commit

Permalink
Merge pull request #39 from phuc-create/copy-images
Browse files Browse the repository at this point in the history
Copy images after compling
  • Loading branch information
phuc-create authored Oct 8, 2023
2 parents 9240c76 + e604f2d commit 79021ac
Show file tree
Hide file tree
Showing 5 changed files with 283 additions and 23 deletions.
4 changes: 4 additions & 0 deletions backend/copy-file.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import fs from 'fs-extra'

// Copy the images folder to the output directory
fs.copySync('./uploads', './dist/uploads')
8 changes: 6 additions & 2 deletions backend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
"main": "server.ts",
"type": "module",
"scripts": {
"build": "tsc",
"start": "node ./dist/server.js",
"build": "tsc && node copy-file.ts",
"start": "node ./dist/copy-file.js && node ./dist/server.js",
"dev": "nodemon server.ts",
"client": "npm start --prefix ../frontend",
"data": "node backend/seederScript.js"
Expand All @@ -27,9 +27,11 @@
"bcrypt": "^5.1.1",
"body-parser": "^1.20.2",
"bson": "^6.1.0",
"copyfiles": "^2.4.1",
"cors": "^2.8.5",
"dotenv": "^16.3.1",
"express": "^4.18.2",
"fs-extra": "^11.1.1",
"jsonwebtoken": "^9.0.2",
"mongoose": "^7.6.0",
"multer": "^1.4.5-lts.1",
Expand All @@ -41,10 +43,12 @@
"@types/cors": "^2.8.14",
"@types/dotenv": "^8.2.0",
"@types/express": "^4.17.18",
"@types/fs-extra": "^11.0.2",
"@types/jsonwebtoken": "^9.0.3",
"@types/multer": "^1.4.8",
"@types/node": "^20.8.3",
"concurrently": "^6.0.0",
"copy-webpack-plugin": "^11.0.0",
"eslint": "^8.50.0",
"nodemon": "^2.0.7",
"prettier": "^3.0.3",
Expand Down
2 changes: 1 addition & 1 deletion backend/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,6 @@
"ts-node": {
"esm": true
},
"include": ["./"],
"include": ["./","uploads"],
"exclude": ["node_modules","dist"]
}
15 changes: 15 additions & 0 deletions backend/webpack.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import CopyWebpackPlugin from 'copy-webpack-plugin'
import path from "path"


module.exports = {
context: path.join(__dirname, 'your-app'),
plugins: [
new CopyWebpackPlugin({
patterns: [
path.resolve(__dirname, "uploads"),
{ from: path.resolve(__dirname, "uploads"), to: path.join(__dirname, "dist/uploads") }
]
})
]
}
Loading

0 comments on commit 79021ac

Please sign in to comment.