Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/toyobayashi/express-serve-asar
A Node.js Express middleware for serving static files inside Electron's asar file.
https://github.com/toyobayashi/express-serve-asar
Last synced: 2 days ago
JSON representation
A Node.js Express middleware for serving static files inside Electron's asar file.
- Host: GitHub
- URL: https://github.com/toyobayashi/express-serve-asar
- Owner: toyobayashi
- License: mit
- Created: 2018-11-08T11:00:53.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2019-08-07T13:46:12.000Z (over 5 years ago)
- Last Synced: 2024-10-11T20:58:33.093Z (27 days ago)
- Language: JavaScript
- Homepage:
- Size: 3.91 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# express-serve-asar
A Node.js Express middleware for serving static files inside Electron's asar file. Also works with webpack-dev-server.
## Usage
``` js
const serveAsar = require('express-serve-asar')
const devServer = require('webpack-dev-server')
const webpack = require('webpack')
const path = require('path')
const webpackConfig = require('./somewhere/webpack.config.js')
const compiler = webpack(webpackConfig)const host = 'localhost'
const port = 3000const contentBase = path.join(__dirname, 'public')
const customResponseHeaders = {
'X-My-Header': '233'
}
/**
* @param {string=} contentBase [Optional] Where the static files is served. Default value is process.cwd().
* @param {object=} customResponseHeaders [Optional] Custom response headers
*/
const middleware = serveAsar(contentBase, customResponseHeaders)const devServerOptions = {
stats: {
colors: true
},
hot: true,
inline: true,
host,
contentBase,
before (app) {
app.use(middleware)
}
}devServer.addDevServerEntrypoints(webpackConfig, devServerOptions)
const server = new devServer(compiler, devServerOptions)
server.listen(port, host, () => {
console.log('webpack server start.')
})
```