You're Invited: Meet the Socket team at BSidesSF and RSAC - April 27 - May 1.RSVP
Socket
Sign inDemoInstall
Socket

rollup-plugin-serve

Package Overview
Dependencies
Maintainers
1
Versions
23
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

rollup-plugin-serve - npm Package Compare versions

Comparing version

to
0.1.0

14

CHANGELOG.md

@@ -7,11 +7,17 @@ # Changelog

## [0.0.2]
## [0.1.0] - 2016-09-29
### Added
- Option `open` open the project in browser
- Option `historyApiFallback`
- Default green favicon
## Changed
- Option `root` is now `contentBase`
## [0.0.1] - 2016-09-24
### Added
- Initial version
[Unreleased]: https://github.com/thgh/rollup-plugin-serve/compare/v0.0.1...HEAD
[0.0.2]: https://github.com/thgh/rollup-plugin-serve/compare/v0.0.1...v0.0.2
[Unreleased]: https://github.com/thgh/rollup-plugin-serve/compare/v0.1.0...HEAD
[0.1.0]: https://github.com/thgh/rollup-plugin-serve/compare/v0.0.1...v0.1.0
[0.0.1]: https://github.com/thgh/rollup-plugin-serve/releases

@@ -23,42 +23,42 @@ 'use strict';

// Remove querystring
var filePath = options.contentBase + request.url.split('?')[0]
var urlPath = request.url.split('?')[0]
var filePath = path.resolve(options.contentBase, '.' + urlPath)
// Load index.html in directories
if (filePath.endsWith('/')) {
filePath += 'index.html'
if (urlPath.endsWith('/')) {
filePath = path.resolve(filePath, 'index.html')
}
fs.readFile('.' + filePath, function (error, content) {
if (error) {
if (error.code === 'ENOENT') {
if (request.url === '/favicon.ico') {
filePath = path.resolve(__dirname, '../dist/favicon.ico')
fs.readFile(filePath, function (error, content) {
if (error) {
notFound(response, filePath)
} else {
found(response, filePath, content)
}
})
} else if (options.historyApiFallback) {
filePath = path.resolve(options.contentBase, 'index.html')
fs.readFile(filePath, function (error, content) {
if (error) {
notFound(response, filePath)
} else {
found(response, filePath, content)
}
})
fs.readFile(filePath, function (error, content) {
if (!error) {
return found(response, filePath, content)
}
if (error.code !== 'ENOENT') {
response.writeHead(500)
response.end('500 Internal Server Error' +
'\n\n' + filePath +
'\n\n' + Object.keys(error).map(function (k) { return error[k]; }).join('\n') +
'\n\n(rollup-plugin-serve)', 'utf-8')
return
}
if (request.url === '/favicon.ico') {
filePath = path.resolve(__dirname, '../dist/favicon.ico')
fs.readFile(filePath, function (error, content) {
if (error) {
notFound(response, filePath)
} else {
found(response, filePath, content)
}
})
} else if (options.historyApiFallback) {
filePath = path.resolve(options.contentBase, 'index.html')
fs.readFile(filePath, function (error, content) {
if (error) {
notFound(response, filePath)
} else {
found(response, filePath, content)
}
} else {
response.writeHead(500)
response.end('500 Internal Server Error' +
'\n\n' + filePath +
'\n\n' + Object.keys(error).map(function (k) { return error[k]; }).join('\n') +
'\n\n(rollup-plugin-serve)', 'utf-8')
}
})
} else {
found(response, filePath, content)
notFound(response, filePath)
}

@@ -75,3 +75,3 @@ })

running = true
console.log('Server running at ' + green(url))
console.log(green(url) + ' -> ' + path.resolve(options.contentBase))

@@ -78,0 +78,0 @@ // Open browser

@@ -19,42 +19,42 @@ import { readFile } from 'fs';

// Remove querystring
var filePath = options.contentBase + request.url.split('?')[0]
var urlPath = request.url.split('?')[0]
var filePath = resolve(options.contentBase, '.' + urlPath)
// Load index.html in directories
if (filePath.endsWith('/')) {
filePath += 'index.html'
if (urlPath.endsWith('/')) {
filePath = resolve(filePath, 'index.html')
}
readFile('.' + filePath, function (error, content) {
if (error) {
if (error.code === 'ENOENT') {
if (request.url === '/favicon.ico') {
filePath = resolve(__dirname, '../dist/favicon.ico')
readFile(filePath, function (error, content) {
if (error) {
notFound(response, filePath)
} else {
found(response, filePath, content)
}
})
} else if (options.historyApiFallback) {
filePath = resolve(options.contentBase, 'index.html')
readFile(filePath, function (error, content) {
if (error) {
notFound(response, filePath)
} else {
found(response, filePath, content)
}
})
readFile(filePath, function (error, content) {
if (!error) {
return found(response, filePath, content)
}
if (error.code !== 'ENOENT') {
response.writeHead(500)
response.end('500 Internal Server Error' +
'\n\n' + filePath +
'\n\n' + Object.keys(error).map(function (k) { return error[k]; }).join('\n') +
'\n\n(rollup-plugin-serve)', 'utf-8')
return
}
if (request.url === '/favicon.ico') {
filePath = resolve(__dirname, '../dist/favicon.ico')
readFile(filePath, function (error, content) {
if (error) {
notFound(response, filePath)
} else {
found(response, filePath, content)
}
})
} else if (options.historyApiFallback) {
filePath = resolve(options.contentBase, 'index.html')
readFile(filePath, function (error, content) {
if (error) {
notFound(response, filePath)
} else {
found(response, filePath, content)
}
} else {
response.writeHead(500)
response.end('500 Internal Server Error' +
'\n\n' + filePath +
'\n\n' + Object.keys(error).map(function (k) { return error[k]; }).join('\n') +
'\n\n(rollup-plugin-serve)', 'utf-8')
}
})
} else {
found(response, filePath, content)
notFound(response, filePath)
}

@@ -71,3 +71,3 @@ })

running = true
console.log('Server running at ' + green(url))
console.log(green(url) + ' -> ' + resolve(options.contentBase))

@@ -74,0 +74,0 @@ // Open browser

{
"name": "rollup-plugin-serve",
"version": "0.0.1",
"version": "0.1.0",
"description": "Serve your rolled up bundle",

@@ -39,3 +39,3 @@ "main": "dist/index.cjs.js",

"devDependencies": {
"rollup": "^0.36.0",
"rollup": "^0.36.1",
"rollup-plugin-buble": "^0.14.0",

@@ -42,0 +42,0 @@ "rollup-watch": "^2.5.0"

@@ -33,9 +33,3 @@ # Rollup plugin to serve the bundle

plugins: [
serve({
// Where to serve files from
contentBase: 'dist/',
// Return index.html instead of 404
historyApiFallback: false
})
serve('dist')
]

@@ -45,2 +39,23 @@ }

### Options
By default it serves the current project folder. Change it by passing a string:
```
serve('public') // will be used as contentBase
// Default options
serve({
// Folder to serve files from,
contentBase: '',
// Set to true to return index.html instead of 404
historyApiFallback: false,
// Options used in setting up server
host: 'localhost',
port: 10001
})
```
>>>>>>> master
## Changelog

@@ -70,2 +85,2 @@

[link-contributors]: ../../contributors
[serve]: https://www.npmjs.com/package/serve
[rollup-plugin-serve]: https://www.npmjs.com/package/rollup-plugin-serve