Browse Source

init base

mrs4z 3 years ago
commit
d4b706cdee
6 changed files with 85 additions and 0 deletions
  1. 7 0
      .editorconfig
  2. 5 0
      .gitignore
  3. 22 0
      README.md
  4. 20 0
      package.json
  5. 3 0
      routes/index.js
  6. 28 0
      server.js

+ 7 - 0
.editorconfig

@@ -0,0 +1,7 @@
+[*.{js,pug,css}]
+indent_style = space
+indent_size = 2
+end_of_line = lf
+trim_trailing_whitespace = true
+insert_final_newline = true
+max_line_length = 100

+ 5 - 0
.gitignore

@@ -0,0 +1,5 @@
+.idea
+node_modules
+package-lock.json
+public/
+views/

+ 22 - 0
README.md

@@ -0,0 +1,22 @@
+#Описание
+Простой инструмент для упрощенной верстке, базовая структура:
+
+```angular2html
+- Шаблонизатор PUG
+- Hot-Reload (авто-перезагрузка сервера при изменении файлов)
+```
+
+#Сущности
+Директория `views` - должна содержать файл `index.pug`
+Директория `public` - для ресурсов, стилей, скриптов и т.д
+
+#Установка и запуск:
+Установка зависимостей
+```angular2html
+npm install
+```
+
+Запускать так:
+```angular2html
+npm run start
+```

+ 20 - 0
package.json

@@ -0,0 +1,20 @@
+{
+  "name": "s4z-main",
+  "version": "1.0.0",
+  "scripts": {
+    "start": "nodemon server.js -e ejs,js,css,html,jpg,png,scss,pug"
+  },
+  "dependencies": {
+    "connect-livereload": "^0.6.1",
+    "express": "^4.17.3",
+    "livereload": "^0.9.3",
+    "nodemon": "^2.0.15",
+    "normalize.css": "^8.0.1",
+    "pug": "^3.0.2"
+  },
+  "author": {
+    "email": "mrs4z@icloud.com",
+    "url": "www.s4z.io",
+    "name": "Alexandr Gordenko"
+  }
+}

+ 3 - 0
routes/index.js

@@ -0,0 +1,3 @@
+exports.index = function(req, res){
+    res.render('index', {});
+};

+ 28 - 0
server.js

@@ -0,0 +1,28 @@
+const express = require('express');
+const http = require('http');
+const index = require('./routes/index.js');
+const livereload = require('livereload');
+const connectLivereload = require('connect-livereload')
+const path = require("path");
+
+const port = 3001;
+const viewsSrc = path.join(__dirname, 'views');
+
+const appLiveReload = livereload.createServer();
+appLiveReload.watch(viewsSrc)
+appLiveReload.server.once("connection", () => {
+    setTimeout(() => {
+        appLiveReload.refresh('/');
+    }, 100);
+})
+
+const app = express();
+app.use(connectLivereload());
+app.use(express.static(path.join(__dirname, 'public')));
+app.set('views', viewsSrc);
+app.set('view engine', 'pug');
+app.get('/', index.index);
+http.createServer(app).listen(port, function(){
+    console.log('Express server listening on port ' + port);
+});
+