forked from thgh/rollup-plugin-serve
npm install --save-dev rollup-plugin-server
// rollup.config.js
import server from 'rollup-plugin-server'
export default {
entry: 'entry.js',
dest: 'bundle.js',
plugins: [
server('dist')
]
// ssl: true, // optional
}
By default it serves the current project folder. Change it by passing a string:
server('public') // will be used as contentBase
// Default options
server({
// Launch in browser (default: false)
open: true,
// Show server address in console (default: true)
verbose: false,
// Folder to serve files from
contentBase: '',
// Multiple folders to serve from
contentBase: ['dist', 'static'],
// Set to true to return index.html instead of 404
historyApiFallback: false,
// Options used in setting up server
host: 'localhost',
port: 10001,
ssl: true, // optional
// @see https://nodejs.org/api/https.html#https_https_createserver_options_requestlistener
ssl_key: fs.readFileSync('server.key'), // optional
ssl_cert: fs.readFileSync('server.crt'), // optional
//ssl_ciphers: ... // optional Intermediate compatibility (default) @see https://wiki.mozilla.org/Security/Server_Side_TLS
// Any data can be set in the response header
customResponseHeaders: {
'X-PING': 'PONG',
// ...
}
})
HTTP
$ cd ./test
$ ../node_modules/.bin/rollup -c rollup.config.js
Browser access : http://localhost:10001, http://localhost:10001/base1, http://localhost:10001/base2
HTTPS
$ cd ./test
$ ../node_modules/.bin/rollup -c rollup.config.ssh.js
Browser access : https://localhost:10001, https://localhost:10001/base1, https://localhost:10001/base2
Contributions and feedback are very welcome.
To get it running:
- Clone the project.
npm install
npm run build
- Kei Funagayama
- Fork source : Thomas Ghysels
The MIT License (MIT). Please see License File for more information.