首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >webpack没有看到文件

webpack没有看到文件
EN

Stack Overflow用户
提问于 2017-03-22 16:41:28
回答 1查看 1.6K关注 0票数 1

tsconfig:

代码语言:javascript
复制
{
    "compilerOptions": {
        "module": "commonjs",
        "target": "es5",
        "sourceMap": true,
        "emitDecoratorMetadata": true,
        "experimentalDecorators": true,
        "noImplicitAny": true,
        "declaration": true
    },
    "files": [
        "sample2-inject/app.ts"
    ],
    "exclude": [
    ]
}

webpack.config.js:

代码语言:javascript
复制
var path = require('path');
module.exports = {
    entry: path.resolve("./sample2-inject/app.ts"),
    output: {
        path: path.resolve("./dist"),
        filename: "bundle.js",
        library: "home"
    },
    resolve: {
        extensions: [".webpack.js", ".web.js", ".ts", ".js"]
    },
    module: {
        loaders: [
            {loader: "ts-loader"}
        ]
    },
    watch: true,
    devtool: "eval"
};

app.ts:

代码语言:javascript
复制
import "es6-shim";
import "reflect-metadata";
import {Container} from "typedi";

错误:

./~/typedi/index.js 528字节{0}生成1个错误。/~/ES6-shim/ES6-shim.js 533字节{0}生成1个错误。/~/Reflect.js 540字节{0}生成1个错误。 错误在./~/Reflect.js模块构建失败:错误:找不到文件:'/home/sesmanovich/www/JQueryPlugins/node_modules/reflect-metadata/Reflect.js'.(/usr/local/lib/node_modules/typescript/lib/typescript.js:81080:23) at Object.getEmitOutput (/usr/local/lib/node_modules/typescript/lib/typescript.js:81446:30) at getEmit (/home/sesmanovich/www/JQueryPlugins/node_modules/ts-loader/dist/index.js:99:43) at Object.loader (/home/sesmanovich/www/JQueryPlugins/node_modules/ts-loader/dist/index.js:27:11) @./sample2-注入/应用程序4:0-27

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2017-03-22 20:52:22

webpack配置:

代码语言:javascript
复制
    loaders: [
        {loader: "ts-loader"}
    ]

是错的。您应该只对ts-loader文件使用ts/tsx

代码语言:javascript
复制
loaders: [ // loaders will work with webpack 1 or 2; but will be renamed "rules" in future
  // all files with a `.ts` or `.tsx` extension will be handled by `ts-loader`
  { test: /\.tsx?$/, loader: 'ts-loader' }
]

更多

参见自述:https://github.com/TypeStrong/ts-loader#configuration

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/42957796

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档