我在我的应用程序的后端(nodejs)上使用webpack,主要是将我的.ts转换为.js。虽然不行。它处理需要controllers文件夹的app.ts,但webpack抱怨:
ERROR in ./app.ts
Module not found: Error: Cannot resolve 'file' or 'directory' ./controllers in C:\Users\markn\Documents\source\ftct
@ ./app.ts 3:18-42
我的webpack.config.js的摘录如下所示:
module.exports = [{
{
// back end
context: app,
entry: {
app: ['webpack/hot/dev-server', './app.ts']
},
target: 'node',
devtool: 'source-map',
output: {
path: app,
filename: 'app.js'
},
externals: nodeModules,
module: {
loaders: [
{ test: /\.ts(x?)$/, loader: 'babel-loader!ts-loader' },
{ test: /\.js$/, loader: 'ng-annotate!babel!jshint', exclude: /node_modules/ },
{ test: /\.json$/, loader: 'json-loader' }
]
},
plugins: [
new webpack.BannerPlugin('require("source-map-support").install();',
{ raw: true, entryOnly: false })
]
}
];
我哪里错了?
答案 0 :(得分:0)
不用担心,找到了答案。好吧,在盯着代码时偶然发现了它。我从配置中遗漏了这个:
resolve: {
extensions: ['', '.webpack.js', '.web.js', '.ts', '.tsx', '.js']
}