Browserify inline script tags in HTML
npm install scriptifyBrowserify inline script tags in HTML.
We have a index.html page with:
``html`
Then as we serve the HTML we can transform it:
`js
var scriptify = require('scriptify')
// Bundle an HTML file
fs.createReadStream('index.html')
.pipe(scriptify())
.pipe(fs.createWriteStream('bundle.html'))
// Or bundle as the server requests it:
var http = require('http')
var fs = require('fs')
http.createServer(function(req, res) {
if (req.url !== '/') return res.end('')
res.writeHead(200, {'Content-Type': 'text/html'})
fs.createReadStream('index.html').pipe(scriptify()).pipe(res)
}).listen(8080)
console.log('Server running at http://localhost:8080/')
`
.-
options:
- selector: Defaults to script[type="text/browserify"].
- args: Defaults to []. Arguments to pass to browserify.Is this a good idea?
I don't know. Probably not. I'm just being lazy and sometimes don't want to have
a separate file for an entry point.install
With npm do:
`
npm install scriptify
``