Showing
4 changed files
with
46 additions
and
2 deletions
asset/js/main.js
0 → 100644
1 | +import "../scss/style.scss"; |
asset/scss/style.scss
0 → 100644
... | @@ -4,7 +4,9 @@ | ... | @@ -4,7 +4,9 @@ |
4 | "description": "make Youtube Website", | 4 | "description": "make Youtube Website", |
5 | "main": "app.js", | 5 | "main": "app.js", |
6 | "scripts": { | 6 | "scripts": { |
7 | - "start": "nodemon --exec babel-node init.js --delay 2" | 7 | + "dev:server": "nodemon --exec babel-node init.js --delay 2", |
8 | + "dev:assets": "WEBPACK_ENV=development webpack", | ||
9 | + "build:assets": "WEBPACK_ENV=production webpack" | ||
8 | }, | 10 | }, |
9 | "repository": { | 11 | "repository": { |
10 | "type": "git", | 12 | "type": "git", |
... | @@ -20,11 +22,14 @@ | ... | @@ -20,11 +22,14 @@ |
20 | "cookie-parser": "^1.4.5", | 22 | "cookie-parser": "^1.4.5", |
21 | "dotenv": "^8.2.0", | 23 | "dotenv": "^8.2.0", |
22 | "express": "^4.17.1", | 24 | "express": "^4.17.1", |
25 | + "extract-text-webpack-plugin": "^4.0.0-beta.0", | ||
23 | "helmet": "^3.22.0", | 26 | "helmet": "^3.22.0", |
24 | "mongoose": "^5.9.15", | 27 | "mongoose": "^5.9.15", |
25 | "morgan": "^1.10.0", | 28 | "morgan": "^1.10.0", |
26 | "multer": "^1.4.2", | 29 | "multer": "^1.4.2", |
27 | - "pug": "^2.0.4" | 30 | + "pug": "^2.0.4", |
31 | + "webpack": "^4.43.0", | ||
32 | + "webpack-cli": "^3.3.11" | ||
28 | }, | 33 | }, |
29 | "devDependencies": { | 34 | "devDependencies": { |
30 | "eslint": "^6.8.0", | 35 | "eslint": "^6.8.0", | ... | ... |
webpack.config.js
0 → 100644
1 | +const path = require("path"); | ||
2 | +const ExtractCSS = require("extract-text-webpack-plugin"); | ||
3 | + | ||
4 | +const MODE = process.env.WEBPACK_ENV; | ||
5 | +const ENTRY_FILE = path.resolve(__dirname, "assets", "js", "main.js"); | ||
6 | +const OUTPUT_DIR = path.join(__dirname, "static"); | ||
7 | + | ||
8 | +const config = { | ||
9 | + entry: ENTRY_FILE, | ||
10 | + mode: MODE, | ||
11 | + module: { | ||
12 | + rules: [ | ||
13 | + { | ||
14 | + test: /\.(scss|sass)$/, | ||
15 | + use: ExtractCSS.extract( | ||
16 | + { | ||
17 | + loader: "css-loader", | ||
18 | + }, | ||
19 | + { | ||
20 | + loader: "postcss-loader", | ||
21 | + }, | ||
22 | + { | ||
23 | + loader: "sass-loader", | ||
24 | + } | ||
25 | + ), | ||
26 | + }, | ||
27 | + ], | ||
28 | + }, | ||
29 | + output: { | ||
30 | + path: OUTPUT_DIR, | ||
31 | + filename: "[name].[format]", | ||
32 | + }, | ||
33 | +}; | ||
34 | + | ||
35 | +module.exports = config; |
-
Please register or login to post a comment