当通过 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", }
]
},
}
}
让 webpack2 编译延迟加载文件 (*.ts) 的正确方法是什么?
起初我在 tsconfig.json 中有compileOnSave: true但这不需要与 webpack 结合使用吗?我错过了什么?
“loremCtrl.ts”是否编译并保存在“rootApp.js”中?我应该如何使用 webpack 来编译延迟加载的文件?