javascript - How should I use moment-timezone with webpack? -
in using webpack build project, typically require modules in commonjs npm modules. need moment-timezone in project, in building package must build data moment-timezone, can quite lot.
additionally build failing following error:
error in ./~/moment-timezone/data/packed/latest.json module parse failed: /site/node_modules/moment-timezone/data/packed/latest.json line 2: unexpected token : may need appropriate loader handle file type. | { | "version": "2015a", | "zones": [ | "africa/abidjan|lmt gmt|g.8 0|01|-2ldxh.q", @ ./~/moment-timezone/index.js 4:15-51
at point not concerned build failing, size of build if succeeds. though, failing build need addressed @ point.
i appreciate pointers on how handle this, if of have encountered same issue using webpack (or browserify too, probably).
you can fix adding json loader webpack configuration.
$npm install json-loader
and add loaders in webpack.config.js. don't forget add extension well.
{ module: { loaders: [ {include: /\.json$/, loaders: ["json-loader"]} ] }, resolve: { extensions: ['', '.json', '.jsx', '.js'] } }