Included custom vulcanize package in repo
This commit is contained in:
1
rpg-docs/.gitignore
vendored
1
rpg-docs/.gitignore
vendored
@@ -1,7 +1,6 @@
|
||||
.meteor/local
|
||||
.meteor/meteorite
|
||||
.demeteorized
|
||||
packages
|
||||
settings.json
|
||||
public/components
|
||||
nohup.out
|
||||
|
||||
3
rpg-docs/packages/meteor-vulcanize/.versions
Normal file
3
rpg-docs/packages/meteor-vulcanize/.versions
Normal file
@@ -0,0 +1,3 @@
|
||||
differential:vulcanize@0.0.5
|
||||
meteor@1.1.6
|
||||
underscore@1.0.3
|
||||
29
rpg-docs/packages/meteor-vulcanize/README.md
Normal file
29
rpg-docs/packages/meteor-vulcanize/README.md
Normal file
@@ -0,0 +1,29 @@
|
||||
Vulcanize
|
||||
==============================================================================
|
||||
This package a meteor build plugin that wraps the [vulcanize](https://www.npmjs.com/package/vulcanize) npm package, which is used to process web components into a single output file.
|
||||
|
||||
### Usage
|
||||
1. Ensure all your components are located somewhere under your public directory.
|
||||
2. Include an `imports.html` file anywhere available to the client, that contains the html imports that would normally go inside your `<head>` tag.
|
||||
|
||||
````
|
||||
<!-- Core Components -->
|
||||
<link rel="import" href="/components/core-animation/core-animation.html">
|
||||
<link rel="import" href="/components/core-animated-pages/core-animated-pages.html">
|
||||
<link rel="import" href="/components/core-animated-pages/transitions/slide-from-right.html">
|
||||
<link rel="import" href="/components/core-drawer-panel/core-drawer-panel.html">
|
||||
<link rel="import" href="/components/core-pages/core-pages.html">
|
||||
...
|
||||
|
||||
<!-- Paper Components -->
|
||||
<link rel="import" href="/components/paper-dialog/paper-action-dialog.html">
|
||||
<link rel="import" href="/components/paper-dialog/paper-dialog-transition.html">
|
||||
<link rel="import" href="/components/paper-input/paper-input.html">
|
||||
...
|
||||
````
|
||||
|
||||
- Running your app in development as usual will result in the contents of `imports.html` being added to your `<head>` tag, resulting in multiple subsequent HTTP requests (good in development - debugging).
|
||||
|
||||
- Running `meteor`, `meteor build`, `modulus deploy`, etc with the `VULCANIZE=true` environment variable set will result in all your html imports being vulcanized or concatenated into a single html import (good in production). The resulting file will be called `vulcanized.html`, which will be automatically added to your `<head>` tag. For example, `VULCANIZE=true meteor`, `VULCANIZE=true modulus deploy`.
|
||||
|
||||
- Setting the `CDN_PREFIX` environment variable will prepend the string to the beginning of the file path that is inserted into your HTML's `<head>` tag.
|
||||
15
rpg-docs/packages/meteor-vulcanize/package.js
Normal file
15
rpg-docs/packages/meteor-vulcanize/package.js
Normal file
@@ -0,0 +1,15 @@
|
||||
Package.describe({
|
||||
name: 'thaum:vulcanize',
|
||||
summary: 'Vulcanize',
|
||||
version: '0.0.5',
|
||||
git: 'https://github.com/Differential/meteor-vulcanize'
|
||||
});
|
||||
|
||||
Package.registerBuildPlugin({
|
||||
name: 'vulcanize',
|
||||
use: [],
|
||||
sources: [
|
||||
'vulcanize.js'
|
||||
],
|
||||
npmDependencies: {'vulcanize': '0.7.11'}
|
||||
});
|
||||
20
rpg-docs/packages/meteor-vulcanize/versions.json
Normal file
20
rpg-docs/packages/meteor-vulcanize/versions.json
Normal file
@@ -0,0 +1,20 @@
|
||||
{
|
||||
"dependencies": [
|
||||
[
|
||||
"meteor",
|
||||
"1.1.3"
|
||||
],
|
||||
[
|
||||
"underscore",
|
||||
"1.0.1"
|
||||
]
|
||||
],
|
||||
"pluginDependencies": [
|
||||
[
|
||||
"vulcanize",
|
||||
{}
|
||||
]
|
||||
],
|
||||
"toolVersion": "meteor-tool@1.0.35",
|
||||
"format": "1.0"
|
||||
}
|
||||
5
rpg-docs/packages/meteor-vulcanize/vulcanize-tests.js
Normal file
5
rpg-docs/packages/meteor-vulcanize/vulcanize-tests.js
Normal file
@@ -0,0 +1,5 @@
|
||||
// Write your tests here!
|
||||
// Here is an example.
|
||||
Tinytest.add('example', function (test) {
|
||||
test.equal(true, true);
|
||||
});
|
||||
70
rpg-docs/packages/meteor-vulcanize/vulcanize.js
Normal file
70
rpg-docs/packages/meteor-vulcanize/vulcanize.js
Normal file
@@ -0,0 +1,70 @@
|
||||
var vulcan = Npm.require('vulcanize');
|
||||
var crypto = Npm.require('crypto');
|
||||
var url = Npm.require('url');
|
||||
|
||||
var _ = Npm.require('underscore');
|
||||
|
||||
var handler = function(compileStep) {
|
||||
var importsHtml = compileStep.read().toString('utf8');
|
||||
|
||||
if (process.env.VULCANIZE) {
|
||||
log('Vulcanizing imports...');
|
||||
vulcanize(compileStep, importsHtml);
|
||||
} else {
|
||||
log('Adding all imports...');
|
||||
addImports(compileStep, importsHtml);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
var vulcanize = function(compileStep, importsHtml) {
|
||||
|
||||
var vulcanOutputHandler = function(filename, data) {
|
||||
|
||||
var filenameHash = crypto.createHash('md5').update(data).digest('hex');
|
||||
var filePath = '/vulcanized-' + filenameHash + '.html';
|
||||
|
||||
compileStep.addAsset({
|
||||
path: filePath,
|
||||
data: data
|
||||
});
|
||||
|
||||
if (_.isString(process.env.CDN_PREFIX)) {
|
||||
filePath = url.resolve(process.env.CDN_PREFIX, filePath);
|
||||
}
|
||||
|
||||
compileStep.addHtml({
|
||||
section: 'head',
|
||||
data: '<link rel="import" href="' + filePath + '">'
|
||||
});
|
||||
};
|
||||
|
||||
vulcan.setOptions({
|
||||
inputSrc: importsHtml,
|
||||
outputHandler: vulcanOutputHandler,
|
||||
abspath: 'public',
|
||||
strip: true
|
||||
}, function(error) {
|
||||
if (error) {
|
||||
log(error);
|
||||
} else {
|
||||
vulcan.processDocument();
|
||||
}
|
||||
});
|
||||
|
||||
};
|
||||
|
||||
var addImports = function(compileStep, importsHtml) {
|
||||
compileStep.addHtml({
|
||||
section: 'head',
|
||||
data: importsHtml
|
||||
});
|
||||
};
|
||||
|
||||
var log = function() {
|
||||
args = _.values(arguments);
|
||||
args.unshift("Vulcanize:");
|
||||
console.log.apply(this, args);
|
||||
};
|
||||
|
||||
Plugin.registerSourceHandler("imports.html", handler);
|
||||
Reference in New Issue
Block a user