I'm trying to gather angular
, localForage
and angular-localForage
with webpack
. My require file looks like this,
// Angular libs
require('../bower_components/angular/angular.min.js')
require('../bower_components/angular-resource/angular-resource.min.js')
require('../bower_components/angular-ui-router/release/angular-ui-router.min.js')
require('../bower_components/angular-bootstrap/ui-bootstrap.min.js')
require('../bower_components/angular-bootstrap/ui-bootstrap-tpls.min.js')
require('../bower_components/localforage/dist/localforage.min.js')
require('../bower_components/angular-localforage/dist/angular-localForage.js')
angular-resource
, angular-ui-router
and ui-bootstrap
worked just fine, but when I require angular-localForage
things started to get complicated. My webpack.config.js
looks like this,
var path = require('path')
module.exports = {
entry: "./src/app/app.js",
output: {
path: './src/assets',
filename: "bundle.js",
publicPath: 'assets/'
}
, module: {
loaders: [
{test: /\.less$/, loader: "style!css!less"},
{test: /\.(woff|woff2)(\?v=\d+\.\d+\.\d+)?$/, loader: 'url?limit=10000&mimetype=application/font-woff'},
{test: /\.ttf(\?v=\d+\.\d+\.\d+)?$/, loader: 'url?limit=10000&mimetype=application/octet-stream'},
{test: /\.eot(\?v=\d+\.\d+\.\d+)?$/, loader: 'file'},
{test: /\.svg(\?v=\d+\.\d+\.\d+)?$/, loader: 'url?limit=10000&mimetype=image/svg+xml'}
]
}
, resolve: {
root: [ path.resolve('./src/bower_components') ]
, moduleDirectories: ['./src/bower_components']
}
};
When I run the applications, on the console I see this error
Uncaught TypeError: Cannot read property 'module' of undefined
Which occurs in line 1 of angular-localForage
code
'use strict';
1: var angularLocalForage = angular.module('LocalForageModule', ['ng']);
2: angularLocalForage.provider('$localForage', function() {
3: var lfInstances = {},
This means that angular
is not entering into that scope. I've tried with imports-loader
and exports-loader
with no success.
Any ideas how this should be done?
angular-localforage
throws meError: Cannot resolve module 'localforage'
. I work arround this with thescript
loader, doingrequire('script!.. angular-localforage')
. – Merth