【发布时间】:2017-12-16 20:45:53
【问题描述】:
当lazyLoading 通过 oclazyloader 为 angularjs 编写脚本文件时:
$stateProvider
.state('tokenReceived', {
url: '/somurl',
//templateUrl: '/views/index.html',
controller: "controllers.loremCtrl",
resolve: {
deps: ['$ocLazyLoad', function ($ocLazyLoad) {
return $ocLazyLoad.load({
files: [
scriptPath + 'loremCtrl.js'
],
cache:false
});
}]
}
})
我的 tsconfig.json 文件看起来像这样
{
"compilerOptions": {
"module": "commonjs",
"typeRoots": [
"./node_modules/@types/"
],
"noImplicitAny": false,
"noEmitOnError": true,
"removeComments": false,
"sourceMap": true,
"target": "es5"
},
"exclude": [
"node_modules",
"wwwroot"
]
}
webpack 里面定义的入口是这样的
module.exports = function (env) {
return Merge(require(`./webpack.${env}.js`), {
entry: {
vendor: [
"jquery",
"toastr"
],
rootApp: "./Scripts/rootApp.js",
},
resolve: {
extensions: [".ts", "tsx", ".js"]
},
module: {
rules: [
//NON-PRE
{ test: /\.ts?$/, loader: "ts-loader" },
{ test: /\.css$/, use: ExtractTextPlugin.extract({ use: ['css-loader'] }) },
//PRE
{ test: /(\.png|\.gif|\.ttf|\.eot|\.woff|\.svg)/, loader: "file-loader", enforce: "pre", },
{ test: /\.js$/, loader: "source-map-loader", enforce: "pre", }
]
},
}
}
什么是让延迟加载的文件(*.ts)被webpack2编译的正确方法?
一开始我在 tsconfig.json 中有 compileOnSave: true 但这不需要与 webpack 结合使用吗?我错过了什么吗?
“loremCtrl.ts”是否编译并保存在“rootApp.js”中?我应该如何使用 webpack 来编译延迟加载的文件?
【问题讨论】:
标签: angularjs webpack oclazyload