【发布时间】:2016-09-20 09:17:58
【问题描述】:
我正在做一个小型 angularjs 项目
我使用 ngRoute 导入:
npm install angular-route -S
我的 index.js 看起来像:
import angular from 'angular';
import {nv_morts} from './components/calculator/mortsList/morts';
import 'angular-route/angular-route';
angular.module('app.starter', ['ngRoute'
]).config(function ($routeProvider) {
$routeProvider
.when("/Calculators", nv_morts);
});
webpack.config:
module: {
loaders: [
// load and compile javascript
{ test: /\.js$/, exclude: /node_modules/, loader:"babel", query: { presets: ['es2015', 'stage-1'] } },
// load css and process less
{ test: /\.css$/, loader: "style!css"},
// load JSON files and HTML
{ test: /\.json$/, loader: "json" },
{ test: /\.html$/, exclude: /node_modules/, loader:"raw" },
// load fonts(inline base64 URLs for <=8k)
{ test: /\.(ttf|eot|svg|otf)$/, loader: "file" },
{ test: /\.woff(2)?$/, loader: "url?limit=8192&minetype=application/font-woff"},
// load images (inline base64 URLs for <=8k images)
{test: /\.(png|jpg)$/, loader: 'url-loader?limit=8192'}
] }
我在 package.json 中有一个脚本
"scripts": {
"prestart": "npm install",
"start": "webpack-dev-server",
"bundle": "cp src/index.html dist/ & webpack -p ./dist/bundle.js"
}
当我在本地工作时 (localhost:8080) 一切正常 当我执行命令时
npm 运行构建
它在“dist”文件夹中构建文件 index.html 和 bundle.js
但是当我把这个文件放在 IIS 文件夹中时,我得到:
无法实例化模块 app.starter,原因如下: 错误:[$injector:unpr] 未知提供者:t
如果我删除对 ngRoute 的依赖,它在 IIS 上也能正常工作
为什么最终的 bundle.js 中不包含 ngRoute?
谢谢大家
【问题讨论】:
标签: javascript angularjs json iis