added more examples
This commit is contained in:
parent
955766be2a
commit
284500f9ee
|
@ -20,6 +20,10 @@ example demonstrating to automatic creation of contexts when using variables in
|
|||
|
||||
example demonstrating contexts in a code-split environment.
|
||||
|
||||
## code-splitted-require.context-amd
|
||||
|
||||
example demonstrating contexts in a code-split environment with AMD.
|
||||
|
||||
## loader
|
||||
|
||||
example demonstrating to usage of loaders.
|
||||
|
@ -40,6 +44,10 @@ example demonstrating merging of chucks with named chucks
|
|||
|
||||
example demonstrating mixing CommonJs and AMD
|
||||
|
||||
## web-worker
|
||||
|
||||
example demonstrating creating WebWorkers with webpack and the worker-loader.
|
||||
|
||||
# Requests
|
||||
|
||||
If you think a example is missing, please report it as issue. :)
|
||||
|
|
|
@ -7,10 +7,9 @@ require = require("../require-polyfill")(require.valueOf());
|
|||
var cp = require('child_process');
|
||||
var tc = require("./template-common");
|
||||
|
||||
var argv = process.argv;
|
||||
argv.shift();
|
||||
argv.shift();
|
||||
var extraArgs = argv.join(" ");
|
||||
var extraArgs = "";
|
||||
if(require("fs").existsSync(require("path").join(process.cwd(), "webpackOptions.js")))
|
||||
extraArgs += "--options webpackOptions.js ";
|
||||
|
||||
cp.exec("node ../../bin/webpack.js --verbose --min "+extraArgs+" example.js js/output.js", function (error, stdout, stderr) {
|
||||
if(stderr)
|
||||
|
|
|
@ -2,6 +2,7 @@ var cp = require('child_process');
|
|||
|
||||
var cmds = [
|
||||
"cd code-splitted-require.context && node build.js",
|
||||
"cd code-splitted-require.context-amd && node build.js",
|
||||
"cd code-splitting && node build.js",
|
||||
"cd coffee-script && node build.js",
|
||||
"cd loader && node build.js",
|
||||
|
@ -11,6 +12,7 @@ var cmds = [
|
|||
"cd named-chucks && node build.js",
|
||||
"cd require.resolve && node build.js",
|
||||
"cd mixed && node build.js",
|
||||
"cd web-worker && node build.js",
|
||||
];
|
||||
|
||||
var stack = function() {
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
require("../build-common");
|
|
@ -0,0 +1,11 @@
|
|||
function getTemplate(templateName, callback) {
|
||||
require(["../require.context/templates/"+templateName], function(tmpl) {
|
||||
callback(tmpl());
|
||||
});
|
||||
}
|
||||
getTemplate("a", function(a) {
|
||||
console.log(a);
|
||||
});
|
||||
getTemplate("b", function(b) {
|
||||
console.log(b);
|
||||
});
|
|
@ -0,0 +1,31 @@
|
|||
# example.js
|
||||
|
||||
``` javascript
|
||||
{{example.js}}
|
||||
```
|
||||
|
||||
# js/output.js
|
||||
|
||||
``` javascript
|
||||
{{js/output.js}}
|
||||
```
|
||||
|
||||
# js/1.output.js
|
||||
|
||||
``` javascript
|
||||
{{js/1.output.js}}
|
||||
```
|
||||
|
||||
# Info
|
||||
|
||||
## Uncompressed
|
||||
|
||||
```
|
||||
{{stdout}}
|
||||
```
|
||||
|
||||
## Minimized (uglify-js, no zip)
|
||||
|
||||
```
|
||||
{{min:stdout}}
|
||||
```
|
|
@ -1,6 +1,6 @@
|
|||
function getTemplate(templateName, callback) {
|
||||
require.ensure([], function(require) {
|
||||
callback(require("../require.context/templates/"+templateName));
|
||||
callback(require("../require.context/templates/"+templateName)());
|
||||
});
|
||||
}
|
||||
getTemplate("a", function(a) {
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
require("../build-common");
|
|
@ -0,0 +1,6 @@
|
|||
var Worker = require("worker!./worker");
|
||||
var worker = new Worker;
|
||||
worker.postMessage("b");
|
||||
worker.onmessage = function(event) {
|
||||
var templateB = event.data; // "This text was generated by template B"
|
||||
}
|
|
@ -0,0 +1,38 @@
|
|||
|
||||
# example.js
|
||||
|
||||
``` javascript
|
||||
{{example.js}}
|
||||
```
|
||||
|
||||
# worker.js
|
||||
|
||||
``` javascript
|
||||
{{worker.js}}
|
||||
```
|
||||
|
||||
# js/output.js
|
||||
|
||||
``` javascript
|
||||
{{js/output.js}}
|
||||
```
|
||||
|
||||
# js/[hash].worker.js
|
||||
|
||||
``` javascript
|
||||
{{js/hash.worker.js}}
|
||||
```
|
||||
|
||||
# Info
|
||||
|
||||
## Uncompressed
|
||||
|
||||
```
|
||||
{{stdout}}
|
||||
```
|
||||
|
||||
## Minimized (uglify-js, no zip)
|
||||
|
||||
```
|
||||
{{min:stdout}}
|
||||
```
|
|
@ -0,0 +1,8 @@
|
|||
module.exports = {
|
||||
worker: {
|
||||
webpack: {
|
||||
output: "hash.worker.js",
|
||||
outputPostfix: ".hash.worker.js"
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,6 @@
|
|||
onmessage = function(event) {
|
||||
var template = event.data;
|
||||
require(["../require.context/templates/" + event.data], function(tmpl) {
|
||||
postMessage(tmpl());
|
||||
});
|
||||
}
|
|
@ -29,6 +29,7 @@
|
|||
}
|
||||
],
|
||||
"devDependencies": {
|
||||
"worker-loader": "0.1.x",
|
||||
"mocha": "*",
|
||||
"should": "*",
|
||||
"vm-browserify": "*",
|
||||
|
|
Loading…
Reference in New Issue