I have react
/redux
application that runs on webpack
and would like to use moment-timezone
library. I already checked How should I use moment-timezone with webpack? issue here in SO and installed json-loader
as it is described in the issue. But still when requiring moment-timezone
in my application as:
const momentTz = require('moment-timezone');
it raises an error:
ERROR in ./~/moment-timezone/index.js
Module not found: Error: Cannot resolve 'file' or 'directory' /path-to-the-project/node_modules/moment-timezone
@ ./~/moment-timezone/index.js 2:15-51
Where the @ ./~/moment-timezone/index.js 2:15-51
is:
moment.tz.load(require('./data/packed/latest.json'));
However when I included the minified version from the build folder it worked properly, as:
const momentTz = require('moment-timezone/builds/moment-timezone-with-data.min');
Update:
webpack configs:
let jsonLoader = require('json-loader');
loaders: [
{
include: /\.json$/,
loaders: [jsonLoader]
}
]