Rollup plugin to serve the bundle
Installation
# Rollup v0.60+ and v1+
npm install --save-dev rollup-plugin-serve
# Rollup v0.59 and below
npm install --save-dev rollup-plugin-serve@0
Usage
import serve from 'rollup-plugin-serve'
export default {
input: 'src/main.js',
output: {
file: 'dist/bundle.js',
format: ...
},
plugins: [
serve('dist')
]
}
Options
By default it serves the current project folder. Change it by passing a string:
serve('public')
serve({
open: true,
openPage: '/different/page',
verbose: false,
contentBase: '',
contentBase: ['dist', 'static'],
historyApiFallback: false,
historyApiFallback: '/200.html',
host: 'localhost',
port: 10001,
https: {
key: fs.readFileSync('/path/to/server.key'),
cert: fs.readFileSync('/path/to/server.crt'),
ca: fs.readFileSync('/path/to/ca.pem')
},
headers: {
'Access-Control-Allow-Origin': '*',
foo: 'bar'
},
mimeTypes: {
'application/javascript': ['js_commonjs-proxy']
}
onListening: function (server) {
const address = server.getAddress()
const host = address.host === '::' ? 'localhost' : address.host
const protocol = this.https ? 'https' : 'http'
console.log(`Server listening at ${protocol}://${host}:${address.port}/`)
}
})
Changelog
Please see CHANGELOG for more information what has changed recently.
Contributing
Contributions and feedback are very welcome.
This project aims to stay lean and close to standards. New features should encourage to stick to standards. Options that match the behaviour of webpack-dev-server are always ok.
To get it running:
- Clone the project.
npm install
npm run build
Credits
License
The MIT License (MIT). Please see License File for more information.