added i18n example, fixed error/warning bug
This commit is contained in:
parent
c06fa378a4
commit
57ddbc0859
|
@ -48,6 +48,10 @@ example demonstrating mixing CommonJs and AMD
|
|||
|
||||
example demonstrating creating WebWorkers with webpack and the worker-loader.
|
||||
|
||||
## i18n
|
||||
|
||||
example demonstrating localization.
|
||||
|
||||
# Requests
|
||||
|
||||
If you think a example is missing, please report it as issue. :)
|
||||
|
|
|
@ -13,6 +13,7 @@ var cmds = [
|
|||
"cd require.resolve && node build.js",
|
||||
"cd mixed && node build.js",
|
||||
"cd web-worker && node build.js",
|
||||
"cd i18n && node build.js",
|
||||
];
|
||||
|
||||
var stack = function() {
|
||||
|
|
|
@ -0,0 +1,101 @@
|
|||
|
||||
# example.js
|
||||
|
||||
``` javascript
|
||||
console.log(__("Hello World"));
|
||||
console.log(__("Missing Text"));
|
||||
```
|
||||
|
||||
# webpack.config.js
|
||||
|
||||
``` javascript
|
||||
var I18nPlugin = require("i18n-webpack-plugin");
|
||||
module.exports = {
|
||||
plugins: [
|
||||
new I18nPlugin(
|
||||
require("./de.json") // or pass null to use defaults
|
||||
)
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
> I recommend to use `new I18nPlugin(null)` for development
|
||||
> and write a small script that generates bundles for every language
|
||||
|
||||
# de.json
|
||||
|
||||
``` javascript
|
||||
{
|
||||
"Hello World": "Hallo Welt"
|
||||
}
|
||||
```
|
||||
|
||||
# js/output.js
|
||||
|
||||
``` javascript
|
||||
/******/ (function webpackBootstrap(modules) {
|
||||
/******/ var installedModules = {};
|
||||
/******/ function require(moduleId) {
|
||||
/******/ if(installedModules[moduleId])
|
||||
/******/ return installedModules[moduleId].exports;
|
||||
/******/ var module = installedModules[moduleId] = {
|
||||
/******/ exports: {},
|
||||
/******/ id: moduleId,
|
||||
/******/ loaded: false
|
||||
/******/ };
|
||||
/******/ modules[moduleId].call(null, module, module.exports, require);
|
||||
/******/ module.loaded = true;
|
||||
/******/ return module.exports;
|
||||
/******/ }
|
||||
/******/ require.e = function requireEnsure(chunkId, callback) {
|
||||
/******/ callback.call(null, require);
|
||||
/******/ };
|
||||
/******/ require.modules = modules;
|
||||
/******/ require.cache = installedModules;
|
||||
/******/ return require(0);
|
||||
/******/ })({
|
||||
/******/ c: "",
|
||||
|
||||
/***/ 0:
|
||||
/*!********************!*\
|
||||
!*** ./example.js ***!
|
||||
\********************/
|
||||
/***/ function(module, exports, require) {
|
||||
|
||||
console.log("Hallo Welt");
|
||||
console.log("Missing Text");
|
||||
|
||||
/***/ }
|
||||
/******/ })
|
||||
|
||||
```
|
||||
|
||||
# Info
|
||||
|
||||
## Uncompressed
|
||||
|
||||
```
|
||||
Hash: 6eb19a8e6a58c779abfd201110649331
|
||||
Time: 17ms
|
||||
Asset Size Chunks Chunk Names
|
||||
output.js 989 0 main
|
||||
chunk {0} output.js (main) 64
|
||||
[0] ./example.js 64 [built] {0}
|
||||
|
||||
ERROR in ./example.js
|
||||
Missing localization: Missing Text
|
||||
```
|
||||
|
||||
## Minimized (uglify-js, no zip)
|
||||
|
||||
```
|
||||
Hash: 6eb19a8e6a58c779abfd201110649331
|
||||
Time: 51ms
|
||||
Asset Size Chunks Chunk Names
|
||||
output.js 308 0 main
|
||||
chunk {0} output.js (main) 64
|
||||
[0] ./example.js 64 [built] {0}
|
||||
|
||||
ERROR in ./example.js
|
||||
Missing localization: Missing Text
|
||||
```
|
|
@ -0,0 +1 @@
|
|||
require("../build-common");
|
|
@ -0,0 +1,3 @@
|
|||
{
|
||||
"Hello World": "Hallo Welt"
|
||||
}
|
|
@ -0,0 +1,2 @@
|
|||
console.log(__("Hello World"));
|
||||
console.log(__("Missing Text"));
|
|
@ -0,0 +1,41 @@
|
|||
|
||||
# example.js
|
||||
|
||||
``` javascript
|
||||
{{example.js}}
|
||||
```
|
||||
|
||||
# webpack.config.js
|
||||
|
||||
``` javascript
|
||||
{{webpack.config.js}}
|
||||
```
|
||||
|
||||
> I recommend to use `new I18nPlugin(null)` for development
|
||||
> and write a small script that generates bundles for every language
|
||||
|
||||
# de.json
|
||||
|
||||
``` javascript
|
||||
{{de.json}}
|
||||
```
|
||||
|
||||
# js/output.js
|
||||
|
||||
``` javascript
|
||||
{{js/output.js}}
|
||||
```
|
||||
|
||||
# Info
|
||||
|
||||
## Uncompressed
|
||||
|
||||
```
|
||||
{{stdout}}
|
||||
```
|
||||
|
||||
## Minimized (uglify-js, no zip)
|
||||
|
||||
```
|
||||
{{min:stdout}}
|
||||
```
|
|
@ -0,0 +1,8 @@
|
|||
var I18nPlugin = require("i18n-webpack-plugin");
|
||||
module.exports = {
|
||||
plugins: [
|
||||
new I18nPlugin(
|
||||
require("./de.json") // or pass null to use defaults
|
||||
)
|
||||
]
|
||||
}
|
|
@ -74,6 +74,12 @@ Compilation.prototype.getModule = function(module) {
|
|||
Compilation.prototype.buildModule = function(module, callback) {
|
||||
this.applyPlugins("build-module", module);
|
||||
module.build(this.options, this, this.resolvers.normal, this.inputFileSystem, function(err) {
|
||||
module.errors.forEach(function(err) {
|
||||
this.errors.push(err);
|
||||
}, this);
|
||||
module.warnings.forEach(function(err) {
|
||||
this.warnings.push(err);
|
||||
}, this);
|
||||
if(err) {
|
||||
this.applyPlugins("failed-module", module);
|
||||
return callback(err);
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "webpack",
|
||||
"version": "0.9.0-beta24",
|
||||
"version": "0.9.0-beta25",
|
||||
"author": "Tobias Koppers @sokra",
|
||||
"description": "Packs CommonJs/AMD Modules for the browser. Allows to split your codebase into multiple bundles, which can be loaded on demand. Support loaders to preprocess files, i.e. json, jade, coffee, css, less, ... and your custom stuff.",
|
||||
"dependencies": {
|
||||
|
@ -37,7 +37,8 @@
|
|||
"script-loader": "0.5.x",
|
||||
"bundle-loader": "0.5.x",
|
||||
"file-loader": "0.5.x",
|
||||
"val-loader": "0.5.x"
|
||||
"val-loader": "0.5.x",
|
||||
"i18n-webpack-plugin": "0.1.x"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=0.6"
|
||||
|
|
Loading…
Reference in New Issue