use webpack instead

This commit is contained in:
Evert Prants 2017-09-15 14:22:48 +03:00
parent 93077c083f
commit d9940a0462
Signed by: evert
GPG Key ID: 1688DA83D222D0B5
5 changed files with 597 additions and 767 deletions

1318
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -8,13 +8,11 @@
"test": "echo \"Error: no test specified\" && exit 1",
"css": "mkdir -p build/style && stylus -o build/style src/style/*.styl",
"css:watch": "mkdir -p build/style && stylus -w -o build/style src/style/*.styl",
"js:main": "mkdir -p build/script && browserify src/script/main.js -o build/script/main.js && uglifyjs --overwrite build/script/main.js",
"js:main:watch": "mkdir -p build/script && watchify src/script/main.js -o build/script/main.js",
"js:admin": "mkdir -p build/script && browserify src/script/admin.js -o build/script/admin.js && uglifyjs --overwrite build/script/admin.js",
"js:admin:watch": "mkdir -p build/script && watchify src/script/admin.js -o build/script/admin.js",
"watch": "concurrently --kill-others \"npm run css:watch\" \"npm run js:main:watch\" \"npm run js:admin:watch\"",
"js": "webpack",
"js:watch": "webpack -w",
"watch": "concurrently --kill-others \"npm run css:watch\" \"npm run js:watch\"",
"clean": "rm -rf build/",
"build": "npm run clean && npm run css && npm run js:main && npm run js:admin"
"build": "npm run clean && npm run css && npm run js"
},
"repository": {
"type": "git",
@ -59,15 +57,14 @@
"uuid": "^3.1.0"
},
"devDependencies": {
"browserify": "^14.4.0",
"concurrently": "^3.5.0",
"eslint-plugin-import": "^2.7.0",
"jquery": "^3.2.1",
"mustache": "^2.3.0",
"standard": "^10.0.3",
"uglify-js": "^1.3.5",
"uglifyjs-webpack-plugin": "^0.4.6",
"watch": "^1.0.2",
"watchify": "^3.9.0"
"webpack": "^3.6.0"
},
"standard": {
"env": {

View File

@ -1,9 +1,7 @@
import express from 'express'
import config from '../../scripts/load-config'
import wrap from '../../scripts/asyncRoute'
import {User} from '../api'
import API from '../api/admin'
import News from '../api/news'
const router = express.Router()
const apiRouter = express.Router()

View File

@ -636,14 +636,11 @@ router.get('/docs/:name', wrap(async (req, res, next) => {
return next()
}
try {
doc = fs.readFileSync(doc, {encoding: 'utf8'})
} catch (e) {
return next(e)
}
res.header('Cache-Control', 'max-age=' + 7 * 24 * 60 * 60 * 1000) // 1 week
res.render('document', {doc: doc})
fs.readFile(doc, {encoding: 'utf8'}, (err, contents) => {
if (err) return next(err)
res.header('Cache-Control', 'max-age=' + 7 * 24 * 60 * 60 * 1000) // 1 week
res.render('document', {doc: contents})
})
}))
/*

16
webpack.config.js Normal file
View File

@ -0,0 +1,16 @@
const path = require('path')
const UglifyJSPlugin = require('uglifyjs-webpack-plugin')
module.exports = {
entry: {
main: './src/script/main.js',
admin: './src/script/admin.js'
},
output: {
path: path.join(__dirname, 'build', 'script'),
filename: '[name].js'
},
plugins: [
new UglifyJSPlugin()
]
}