Arrange assets folder

pull/282/head
Amio 2019-06-05 14:47:05 +08:00
rodzic 8b14255ac0
commit 7144e5e542
4 zmienionych plików z 18 dodań i 9 usunięć

Wyświetl plik

@ -12,20 +12,22 @@ const sendError = (req, res, error) => {
}
const badgeHandlers = fs.readdirSync(path.join(__dirname, 'endpoints'))
.filter(name => !name.startsWith('_'))
.map(name => name.replace(/\.ts$/, ''))
.filter(name => /\.[jt]s$/.test(name))
.map(name => name.replace(/\.[jt]s$/, ''))
const isStatic = (url) => {
if (url === '/') return true
if (url.startsWith('/static/')) return true
if (url.startsWith('/_next/')) return true
if (url.startsWith('/static/')) return true
if (url.startsWith('/builder')) return true
return false
}
const { PUB_DIR = '.' } = process.env
const server = http.createServer(async (req, res) => {
// handle statics
if (isStatic(req.url)) {
return serveHandler(req, res, { public: path.join(__dirname, 'dist') })
return serveHandler(req, res, { public: path.resolve(__dirname, PUB_DIR) })
}
// handle `/docs/:name`

Wyświetl plik

@ -1,3 +1,9 @@
module.exports = {
target: 'serverless'
target: 'serverless',
exportPathMap: async function (defaultPathMap) {
return {
'/': { page: '/index' },
'/builder': { page: '/builder' }
}
}
}

Wyświetl plik

@ -6,11 +6,12 @@
"private": true,
"scripts": {
"lint": "standard",
"predev": "npm run now-build",
"dev": "nodemon -e ts,js -w endpoints -w libs -x 'ts-node index.ts'",
"build": "npm run tools && next build && next export -o dist && tsc",
"predev": "npm run build",
"dev": "PUB_DIR=dist nodemon -e ts,js -w endpoints -w libs -x 'ts-node index.ts'",
"dev:web": "next",
"tools": "ts-node tools/gen-examples.ts",
"now-build": "npm run tools && next build && next export -o dist",
"now-build": "npm run build",
"pretest": "npm run lint",
"test": "tap test/*.js --reporter spec -j12",
"start": "node service.js",

Wyświetl plik

@ -10,7 +10,7 @@
"moduleResolution": "node",
"esModuleInterop": true,
"sourceMap": true,
"outDir": "dist-server",
"outDir": "dist",
"baseUrl": ".",
"lib": ["dom", "esnext"]
},