【问题标题】:webpack not transpiling my .ts as expectedwebpack 没有按预期转换我的 .ts
【发布时间】:2015-12-09 20:09:30
【问题描述】:

我在我的应用程序的后端 (nodejs) 上使用 webpack,主要是将我的 .ts 转换为 .js。但它不起作用。它处理需要控制器文件夹的 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 })
        ]
    }
];

我哪里错了?

【问题讨论】:

    标签: node.js webpack visual-studio-code


    【解决方案1】:

    别着急,找到答案了。好吧,在盯着代码看时偶然发现了它。我的配置中缺少这个:

    resolve: {
        extensions: ['', '.webpack.js', '.web.js', '.ts', '.tsx', '.js']
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2021-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-06-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多