44 "readme": "[](https:/
/npmjs.org/package/vulcanize)\n[](https://travis-ci.org/Polymer/vulcanize)\n\n# Vulcanize\n\n
### Concatenate a set of Web Components into one file\n\n>Named for the [Vulcani
zation](http://en.wikipedia.org/wiki/Vulcanization) process that turns polymers
into more durable\nmaterials.\n\n## Installation\n\n`vulcanize` is available on
npm. For maximium utility, `vulcanize` should be installed globally.\n\n sudo
npm install -g vulcanize\n\nThis will install `vulcanize` to `/usr/local/bin/vu
lcanize`.\n\n## Usage\n\n vulcanize index.html\n\nAt the simplest, `vulcanize
` only requires an html file as an argument. The optimized output file will be n
amed\n`vulcanized.html`.\n\nIf you want to control the output name, use the `-o`
flag\n\n vulcanize -o build.html index.html\n\nMost URLs will be automatical
ly adjusted by the vulcanizer.\n\n\n## Options\n\n- `--output`, `-o`\n - Outpu
t file name (defaults to vulcanized.html)\n- `--verbose`, `-v`\n - More verbos
e logging\n- `--help`, `-v`, `-?`\n - Print this message\n- `--config`\n - Re
ad a given config file\n- `--strip`, `-s`\n - Remove comments and empty text no
des\n- `--csp`\n - Extract inline scripts to a separate file (uses `<output fi
le name>`.js)\n- `--inline`\n - The opposite of CSP mode, inline all assets (s
cript and css) into the document\n- `--inline --csp`\n - Bundle all javascript
(inline and external) into `<output file name>`.js\n- `--abspath`, `-p`\n - Spe
cify site root. Resolve paths to absolute paths based on site root\n- `--no-stri
p-excludes`\n - Keep imports excluded from inlining\n- `--version`, ` -V`\n -
print version information\n\n## Additional options when used as Node module\n\nI
n addition to the above options, `vulcan` when used as Node module has additiona
l options for string-based rather than file-based document processing. These are
:\n\n- `inputSrc`\n - The document to process, represented as String, String Bu
ffer, or any Object with a `toString` function that yields valid HTML souce. Imp
orts are resolved relative to the directory in which the node process was starte
d.\n- `outputHandler`\n - An output handler function to call rather than writin
g the processing result to file. The handler must be of the form `function(filen
ame, data)`, which is called with the following arguments:\n - `filename`\n
- The file that vulcanize would create if it were running in file I/O mode.\
n - `data`\n - The HTML source that vulcanize writes to file if no outp
uthandler is used.\n\nAn example of using these options is shown below:\n\n```\n
var vulcan = require(\"./lib/vulcan\");\n\nvar head = \"<head><link rel='import'
href='test/html/imports/simple-import.html'></head>\";\nvar body = \"<body><my-
element>test</my-element></body>\";\nvar input = \"<!doctype><html>\" + head + b
ody + \"</html>\";\n\nvar outputHandler = function(filename, data) {\n console.
log(data);\n};\n\nvulcan.setOptions({inputSrc: input, outputHandler: outputHandl
er}, function(err) {\n if(err) {\n console.error(err);\n process.exit(1);
\n }\n vulcan.processDocument();\n});\n\n```\n\n## Config\n> JSON file for add
itional options\n\n- Excludes: Remove the selected urls from the vulcanized bund
le:\n\n### Example Config\n```json\n{\n \"excludes\": {\n \"imports\": [\n
\"regex-to-exclude\"\n ]\n }\n}\n```\n\n## Example Usage\n\nSay we have
three html files: `index.html`, `x-app.html`, and `x-dep.html`.\n\nindex.html:\n
\n```html\n<!DOCTYPE html>\n<link rel=\"import\" href=\"x-app.html\">\n<x-app></
x-app>\n```\n\nx-app.html:\n\n```html\n<link rel=\"import\" href=\"path/to/x-dep
.html\">\n<polymer-element name=\"x-app\">\n <template>\n <x-dep></x-dep>\n
</template>\n <script>Polymer('x-app')</script>\n</polymer-element>\n```\n\nx-
dep.html:\n\n```html\n<polymer-element name=\"x-dep\">\n <template>\n <img s
rc=\"x-dep-icon.jpg\">\n </template>\n <script>\n Polymer('x-dep');\n </sc
ript>\n</polymer-element>\n```\n\nRunning vulcan on `index.html`, and specifying
`build.html` as the output:\n\n vulcanize -o build.html index.html\n\nWill r
esult in `build.html` that appears as so:\n\n```html\n<!DOCTYPE html>\n<div hidd
en><polymer-element name=\"x-dep\" assetpath=\"path/to/\">\n <template>\n <i
mg src=\"http://www.polymer-project.org/images/logos/p-logo.svg\">\n </template
>\n <script>\n Polymer('x-dep');\n </script>\n</polymer-element>\n\n<polyme
r-element name=\"x-app\" assetpath=\"\">\n <template>\n <x-dep></x-dep>\n <
/template>\n <script>Polymer('x-app')</script>\n</polymer-element>\n</div>\n<x-
app></x-app>\n```\n\n## Content Security Policy\n[Content Security Policy](http:
//en.wikipedia.org/wiki/Content_Security_Policy), or CSP, is a Javascript securi
ty model\nthat aims to prevent XSS and other attacks. In so doing, it prohibits
the use of inline scripts.\n\nTo help automate the use of Polymer element regist
ration with CSP, the `--csp` flag to vulcan will remove all scripts\nfrom the HT
ML Imports and place their contents into an output javascript file.\n\nUsing the
previous example, the output from `vulcanize --csp -o build.html index.html` wi
ll be\n\nbuild.html:\n```html\n<!DOCTYPE html>\n<div hidden><polymer-element nam
e=\"x-dep\" assetpath=\"path/to/\">\n <template>\n <img src=\"http://www.pol
ymer-project.org/images/logos/p-logo.svg\">\n </template>\n\n</polymer-element>
\n\n<polymer-element name=\"x-app\" assetpath=\"\">\n <template>\n <x-dep></
x-dep>\n </template>\n\n</polymer-element>\n</div>\n<x-app></x-app>\n<script sr
c=\"build.js\"></script>\n```\n\nbuild.js:\n```js\n\n Polymer('x-dep');\n ;\
nPolymer('x-app')\n```\n\nThe JS files can become a bit messy without reformatti
ng, and semi-colons are inserted between script contents as a\nprecaution.\n\n##
Stripping whitespace\n\nVulcanize includes a set of size reducing heuristics to
remove unnecessary whitespace and comments in HTML, JS, and CSS.\nThis can be a
ctivated by using the `--strip` option.\n\nUsing the previous example, the outpu
t from `vulcanize --csp -o build.html --strip index.html` will be\n\nbuild.html:
\n```html\n<!DOCTYPE html>\n<div hidden><polymer-element name=\"x-dep\" assetpat
h=\"path/to/\"><template><img src=\"http://www.polymer-project.org/images/logos/
p-logo.svg\"></template></polymer-element><polymer-element name=\"x-app\" assetp
ath=\"\"><template><x-dep></x-dep></template></polymer-element></div>\n<x-app></
x-app>\n<script src=\"build.js\"></script>\n```\n\n```js\nPolymer(\"x-dep\");Pol
ymer(\"x-app\");\n```\n\n[](https://github.com/igrigorik/ga-beacon)\n", | 43 "readme": "[](https:/
/npmjs.org/package/vulcanize)\n[](https://travis-ci.org/Polymer/vulcanize)\n\n# Vulcanize\n\n
### Concatenate a set of Web Components into one file\n\n>Named for the [Vulcani
zation](http://en.wikipedia.org/wiki/Vulcanization) process that turns polymers
into more durable\nmaterials.\n\n## Installation\n\n`vulcanize` is available on
npm. For maximium utility, `vulcanize` should be installed globally.\n\n sudo
npm install -g vulcanize\n\nThis will install `vulcanize` to `/usr/local/bin/vu
lcanize`.\n\n## Usage\n\n vulcanize index.html\n\nAt the simplest, `vulcanize
` only requires an html file as an argument. The optimized output file will be n
amed\n`vulcanized.html`.\n\nIf you want to control the output name, use the `-o`
flag\n\n vulcanize -o build.html index.html\n\nMost URLs will be automatical
ly adjusted by the vulcanizer.\n\n\n## Options\n\n- `--output`, `-o`\n - Outpu
t file name (defaults to vulcanized.html)\n- `--verbose`, `-v`\n - More verbos
e logging\n- `--help`, `-v`, `-?`\n - Print this message\n- `--config`\n - Re
ad a given config file\n- `--strip`, `-s`\n - Remove comments and empty text no
des\n- `--csp`\n - Extract inline scripts to a separate file (uses `<output fi
le name>`.js)\n- `--inline`\n - The opposite of CSP mode, inline all assets (s
cript and css) into the document\n- `--inline --csp`\n - Bundle all javascript
(inline and external) into `<output file name>`.js\n- `--abspath`, `-p`\n - Spe
cify site root. Resolve paths to absolute paths based on site root\n- `--no-stri
p-excludes`\n - Keep imports excluded from inlining\n- `--version`, ` -V`\n -
print version information\n\n## Additional options when used as Node module\n\nI
n addition to the above options, `vulcan` when used as Node module has additiona
l options for string-based rather than file-based document processing. These are
:\n\n- `inputSrc`\n - The document to process, represented as String, String Bu
ffer, or any Object with a `toString` function that yields valid HTML souce. Imp
orts are resolved relative to the directory in which the node process was starte
d.\n- `outputHandler`\n - An output handler function to call rather than writin
g the processing result to file. The handler must be of the form `function(filen
ame, data)`, which is called with the following arguments:\n - `filename`\n
- The file that vulcanize would create if it were running in file I/O mode.\
n - `data`\n - The HTML source that vulcanize writes to file if no outp
uthandler is used.\n\nAn example of using these options is shown below:\n\n```\n
var vulcan = require(\"./lib/vulcan\");\n\nvar head = \"<head><link rel='import'
href='test/html/imports/simple-import.html'></head>\";\nvar body = \"<body><my-
element>test</my-element></body>\";\nvar input = \"<!doctype><html>\" + head + b
ody + \"</html>\";\n\nvar outputHandler = function(filename, data) {\n console.
log(data);\n};\n\nvulcan.setOptions({inputSrc: input, outputHandler: outputHandl
er}, function(err) {\n if(err) {\n console.error(err);\n process.exit(1);
\n }\n vulcan.processDocument();\n});\n\n```\n\n## Config\n> JSON file for add
itional options\n\n- Excludes: Remove the selected urls from the vulcanized bund
le:\n\n### Example Config\n```json\n{\n \"excludes\": {\n \"imports\": [\n
\"regex-to-exclude\"\n ]\n }\n}\n```\n\n## Example Usage\n\nSay we have
three html files: `index.html`, `x-app.html`, and `x-dep.html`.\n\nindex.html:\n
\n```html\n<!DOCTYPE html>\n<link rel=\"import\" href=\"x-app.html\">\n<x-app></
x-app>\n```\n\nx-app.html:\n\n```html\n<link rel=\"import\" href=\"path/to/x-dep
.html\">\n<polymer-element name=\"x-app\">\n <template>\n <x-dep></x-dep>\n
</template>\n <script>Polymer('x-app')</script>\n</polymer-element>\n```\n\nx-
dep.html:\n\n```html\n<polymer-element name=\"x-dep\">\n <template>\n <img s
rc=\"x-dep-icon.jpg\">\n </template>\n <script>\n Polymer('x-dep');\n </sc
ript>\n</polymer-element>\n```\n\nRunning vulcan on `index.html`, and specifying
`build.html` as the output:\n\n vulcanize -o build.html index.html\n\nWill r
esult in `build.html` that appears as so:\n\n```html\n<!DOCTYPE html>\n<div hidd
en><polymer-element name=\"x-dep\" assetpath=\"path/to/\">\n <template>\n <i
mg src=\"http://www.polymer-project.org/images/logos/p-logo.svg\">\n </template
>\n <script>\n Polymer('x-dep');\n </script>\n</polymer-element>\n\n<polyme
r-element name=\"x-app\" assetpath=\"\">\n <template>\n <x-dep></x-dep>\n <
/template>\n <script>Polymer('x-app')</script>\n</polymer-element>\n</div>\n<x-
app></x-app>\n```\n\n## Content Security Policy\n[Content Security Policy](http:
//en.wikipedia.org/wiki/Content_Security_Policy), or CSP, is a Javascript securi
ty model\nthat aims to prevent XSS and other attacks. In so doing, it prohibits
the use of inline scripts.\n\nTo help automate the use of Polymer element regist
ration with CSP, the `--csp` flag to vulcan will remove all scripts\nfrom the HT
ML Imports and place their contents into an output javascript file.\n\nUsing the
previous example, the output from `vulcanize --csp -o build.html index.html` wi
ll be\n\nbuild.html:\n```html\n<!DOCTYPE html>\n<div hidden><polymer-element nam
e=\"x-dep\" assetpath=\"path/to/\">\n <template>\n <img src=\"http://www.pol
ymer-project.org/images/logos/p-logo.svg\">\n </template>\n\n</polymer-element>
\n\n<polymer-element name=\"x-app\" assetpath=\"\">\n <template>\n <x-dep></
x-dep>\n </template>\n\n</polymer-element>\n</div>\n<x-app></x-app>\n<script sr
c=\"build.js\"></script>\n```\n\nbuild.js:\n```js\n\n Polymer('x-dep');\n ;\
nPolymer('x-app')\n```\n\nThe JS files can become a bit messy without reformatti
ng, and semi-colons are inserted between script contents as a\nprecaution.\n\n##
Stripping whitespace\n\nVulcanize includes a set of size reducing heuristics to
remove unnecessary whitespace and comments in HTML, JS, and CSS.\nThis can be a
ctivated by using the `--strip` option.\n\nUsing the previous example, the outpu
t from `vulcanize --csp -o build.html --strip index.html` will be\n\nbuild.html:
\n```html\n<!DOCTYPE html>\n<div hidden><polymer-element name=\"x-dep\" assetpat
h=\"path/to/\"><template><img src=\"http://www.polymer-project.org/images/logos/
p-logo.svg\"></template></polymer-element><polymer-element name=\"x-app\" assetp
ath=\"\"><template><x-dep></x-dep></template></polymer-element></div>\n<x-app></
x-app>\n<script src=\"build.js\"></script>\n```\n\n```js\nPolymer(\"x-dep\");Pol
ymer(\"x-app\");\n```\n\n[](https://github.com/igrigorik/ga-beacon)\n", |