momentjs - Webpack require moment with global reference -


so i've tried multiple approaches no matter 'moment' isn't available globally. frustrating. can point me in right direction here?

var webpack = require('webpack'); var extracttextplugin = require('extract-text-webpack-plugin');  module.exports = {     entry: {         vendor: "./app/vendor.js"     },     resolve: {         alias: {             jquery: "jquery/src/jquery",         }     },     module: {         loaders: [             {                 test: /\.css/,                 loader: extracttextplugin.extract("css-loader")             },             {                 test: /\.(png|jpg|gif)$/,                 loader: "file-loader?name=app/img/[name].[ext]"             }         ]     },     plugins: [         new webpack.provideplugin({           $: "jquery",           jquery: "jquery",           moment: "moment"         }),         new extracttextplugin("app/styles.css")     ],     output: {         filename: "./app/[name].bundle.js"     } } 

if notice below, had use window.d3 make d3 available globally because adding webpack.providerplugin wasn't working d3 specifically. same thing moment, window.moment , var moment = require isn't working either.

window.d3 = require('d3');  require("jquery"); require('jquery-ui/ui/core'); require('jquery-ui/ui/widgets/datepicker');  require('lodash'); require('angular');  require('chosen-js'); require('chosen-js/chosen.css');  var moment = require('moment/min/moment-with-locales.js'); require('moment-timezone/builds/moment-timezone-with-data-2010-2020.js') 

@arjun — yes expose-loader works me. thank you! https://github.com/webpack-contrib/expose-loader

require('expose-loader?moment!moment'); 

Comments

Popular posts from this blog

ubuntu - PHP script to find files of certain extensions in a directory, returns populated array when run in browser, but empty array when run from terminal -

php - How can i create a user dashboard -

javascript - How to detect toggling of the fullscreen-toolbar in jQuery Mobile? -