Last active
April 28, 2017 00:26
-
-
Save jbellenger/2eac00cc0179254bde92bcbb4b7dba7b to your computer and use it in GitHub Desktop.
building globalize-webpack-plugin with webpack2
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
webpackJsonp([0],{ | |
/***/ 11: | |
/***/ (function(module, exports) { | |
/***/ }) | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
webpackJsonp([4,3],{ | |
/***/ 8: | |
/***/ (function(module, exports, __webpack_require__) { | |
(function( root, factory ) { | |
// UMD returnExports | |
if ( false ) { | |
// AMD | |
define( ["globalize-runtime/number","globalize-runtime/plural","globalize-runtime/message","globalize-runtime/currency","globalize-runtime/date","globalize-runtime/relative-time","globalize-runtime/unit"], factory ); | |
} else if ( typeof exports === "object" ) { | |
// Node, CommonJS | |
module.exports = factory( __webpack_require__(1), __webpack_require__(2), __webpack_require__(5), __webpack_require__(3), __webpack_require__(4), __webpack_require__(6), __webpack_require__(7) ); | |
} else { | |
// Global | |
factory( root.Globalize ); | |
} | |
}( this, function( Globalize ) { | |
var validateParameterTypeNumber = Globalize._validateParameterTypeNumber; | |
var validateParameterPresence = Globalize._validateParameterPresence; | |
var numberRound = Globalize._numberRound; | |
var numberFormat = Globalize._numberFormat; | |
var numberFormatterFn = Globalize._numberFormatterFn; | |
var pluralGeneratorFn = Globalize._pluralGeneratorFn; | |
var validateParameterTypeMessageVariables = Globalize._validateParameterTypeMessageVariables; | |
var messageFormat = Globalize._messageFormat; | |
var messageFormatterFn = Globalize._messageFormatterFn; | |
var currencyNameFormat = Globalize._currencyNameFormat; | |
var currencyFormatterFn = Globalize._currencyFormatterFn; | |
var validateParameterTypeDate = Globalize._validateParameterTypeDate; | |
var dateFormat = Globalize._dateFormat; | |
var dateFormatterFn = Globalize._dateFormatterFn; | |
var relativeTimeFormatterFn = Globalize._relativeTimeFormatterFn; | |
var unitFormatterFn = Globalize._unitFormatterFn; | |
Globalize.a71712650 = numberFormatterFn(["",,1,0,2,,,,3,,"","#,##0.###","-#,##0.###","-","",numberRound(),"∞","NaN",{".":".",",":",","%":"%","+":"+","-":"-","E":"E","‰":"‰"},]); | |
Globalize.b957349717 = numberFormatterFn(["'$'",,1,2,2,,,0,3,,"","'$'#,##0.00","-'$''$'#,##0.00","-'$'","",numberRound(),"∞","NaN",{".":".",",":",","%":"%","+":"+","-":"-","E":"E","‰":"‰"},]); | |
Globalize.a1378886668 = numberFormatterFn(["",,1,,,,,,,,"","0","-0","-","",numberRound(),"∞","NaN",{".":".",",":",","%":"%","+":"+","-":"-","E":"E","‰":"‰"},]); | |
Globalize.b203855544 = numberFormatterFn(["",,2,,,,,,,,"","00","-00","-","",numberRound(),"∞","NaN",{".":".",",":",","%":"%","+":"+","-":"-","E":"E","‰":"‰"},]); | |
Globalize.b468386326 = numberFormatterFn(["",,1,0,3,,,,3,,"","#,##0.###","-#,##0.###","-","",numberRound(),"∞","NaN",{".":".",",":",","%":"%","+":"+","-":"-","E":"E","‰":"‰"},]); | |
Globalize.a1662346136 = pluralGeneratorFn(function(n) { | |
var s = String(n).split('.'), v0 = !s[1]; | |
return (n == 1 && v0) ? 'one' : 'other'; | |
}); | |
Globalize.b210121927 = messageFormatterFn((function( ) { | |
return function (d) { return "Unit"; } | |
})(), Globalize("en").pluralGenerator({})); | |
Globalize.a1180651252 = messageFormatterFn((function( number, plural, pluralFuncs ) { | |
return function (d) { return "An example of a message with pluralization support: " + plural(d.count, 0, pluralFuncs.en, { one: function() { return "You have one remaining task";}, other: function() { return "You have " + number(d.count) + " remaining tasks";} }) + "."; } | |
})(messageFormat.number, messageFormat.plural, {"en": Globalize("en").pluralGenerator()}), Globalize("en").pluralGenerator({})); | |
Globalize.a1180650291 = messageFormatterFn((function( ) { | |
return function (d) { return "An example of a message using mixed number \"" + d.number + "\", currency \"" + d.currency + "\", date \"" + d.date + "\", relative time \"" + d.relativeTime + "\", and unit \"" + d.unit + "\"."; } | |
})(), Globalize("en").pluralGenerator({})); | |
Globalize.a723349021 = messageFormatterFn((function( ) { | |
return function (d) { return "Relative Time"; } | |
})(), Globalize("en").pluralGenerator({})); | |
Globalize.a640022104 = messageFormatterFn((function( ) { | |
return function (d) { return "Use Globalize to internationalize your application."; } | |
})(), Globalize("en").pluralGenerator({})); | |
Globalize.b720011458 = messageFormatterFn((function( ) { | |
return function (d) { return "Number"; } | |
})(), Globalize("en").pluralGenerator({})); | |
Globalize.a827835206 = messageFormatterFn((function( ) { | |
return function (d) { return "Currency"; } | |
})(), Globalize("en").pluralGenerator({})); | |
Globalize.b1338632349 = messageFormatterFn((function( ) { | |
return function (d) { return "Date"; } | |
})(), Globalize("en").pluralGenerator({})); | |
Globalize.b1223214380 = currencyFormatterFn(Globalize("en").numberFormatter({"raw":"'$'#,##0.00"})); | |
Globalize.b1998581093 = dateFormatterFn({"1":Globalize("en").numberFormatter({"raw":"0"}),"2":Globalize("en").numberFormatter({"raw":"00"})}, {"pattern":"MMM d, y, h:mm:ss a","timeSeparator":":","months":{"M":{"3":{"1":"Jan","2":"Feb","3":"Mar","4":"Apr","5":"May","6":"Jun","7":"Jul","8":"Aug","9":"Sep","10":"Oct","11":"Nov","12":"Dec"}}},"dayPeriods":{"am":"AM","pm":"PM"}}); | |
Globalize.a776330236 = relativeTimeFormatterFn(Globalize("en").numberFormatter({}), Globalize("en").pluralGenerator({}), {"relativeTime-type-future":{"relativeTimePattern-count-one":"in {0} second","relativeTimePattern-count-other":"in {0} seconds"},"relativeTime-type-past":{"relativeTimePattern-count-one":"{0} second ago","relativeTimePattern-count-other":"{0} seconds ago"},"relative-type-0":"now"}); | |
Globalize.b1315797357 = unitFormatterFn(Globalize("en").numberFormatter({}), Globalize("en").pluralGenerator({}), {"compoundUnitPattern":"{0}/{1}","unitProperties":{"displayName":"miles/hour","one":"{0} mph","other":"{0} mph"}}); | |
Globalize.locale("en"); return Globalize; | |
})); | |
/***/ }) | |
},[11]); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var webpack = require( "webpack" ); | |
var CommonsChunkPlugin = require( "webpack/lib/optimize/CommonsChunkPlugin" ); | |
var HtmlWebpackPlugin = require( "html-webpack-plugin" ); | |
var GlobalizePlugin = require( "globalize-webpack-plugin" ); | |
var path = require('path'); | |
module.exports = { | |
entry: { | |
main: './app/index.js', | |
vendor: [ | |
"globalize", | |
"globalize/dist/globalize-runtime/number", | |
"globalize/dist/globalize-runtime/currency", | |
"globalize/dist/globalize-runtime/date", | |
"globalize/dist/globalize-runtime/message", | |
"globalize/dist/globalize-runtime/plural", | |
"globalize/dist/globalize-runtime/relative-time", | |
"globalize/dist/globalize-runtime/unit" | |
] | |
}, | |
output: { | |
path: path.resolve('./dist'), | |
publicPath: "", | |
filename: "[name].[chunkhash].js" | |
}, | |
resolve: { | |
// - configuration.resolve.extensions[0] should not be empty | |
// extensions: [ "", ".js" ] | |
extensions: [ ".js" ] | |
}, | |
plugins: [ | |
// new webpack.NamedModulesPlugin(), | |
new HtmlWebpackPlugin({ | |
production: true, | |
template: "./index-template.html" | |
}), | |
new GlobalizePlugin({ | |
production: true, | |
developmentLocale: "en", | |
supportedLocales: [ "ar", /*"de",*/ "en", /*"es", "pt", "ru", "zh"*/ ], | |
messages: "messages/[locale].json", | |
output: "i18n/[locale].[hash].js" | |
}), | |
new CommonsChunkPlugin({ | |
name: ['vendor', 'manifest'], | |
filename: '[name].[hash].js', | |
minChunks: Infinity | |
}), | |
// creates a '0' chunk that contains an empty module with id 11 that | |
// the en bundle executes for some reason. | |
// The 0.app chunk is never loaded, causing the en chunk to fail to load. | |
// - what was that module supposed to contain? | |
new webpack.optimize.CommonsChunkPlugin({ | |
async: 'shared', | |
children: true, | |
minChunks: 2 | |
}) | |
] | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment