我正在尝试收集angular
,localForage
并angular-localForage
与webpack
。我的要求文件看起来像这样,
// 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
并且ui-bootstrap
工作得很好,但是当我需要时angular-localForage
事情开始变得复杂。我的webpack.config.js
长相是这样的
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']
}
};
当我运行应用程序时,在控制台上我看到了这个错误
Uncaught TypeError: Cannot read property 'module' of undefined
发生在angular-localForage
代码的第 1 行
'use strict';
1: var angularLocalForage = angular.module('LocalForageModule', ['ng']);
2: angularLocalForage.provider('$localForage', function() {
3: var lfInstances = {},
这意味着angular
没有进入该范围。我试过了imports-loader
,exports-loader
但没有成功。
有什么想法应该怎么做?