2017-04-20 14 views
2

スクリプトをバンドルするためにwebpackを取得できません。 @NgModule({モジュールの解析に失敗しました:* .ts予期しない文字 '@'

私はメッセージを取得します:私はapp.module.tsに、このラインからのエラーを取得します。あなたはこのファイルタイプを処理するために、適切なローダーが必要な場合があります

ここに私のWebPACKの設定があります:

var ExtractTextPlugin = require('extract-text-webpack-plugin'); 

module.exports = { 
    entry: ["./src/ts/main.ts","./src/ts/css.ts"], 
    module: { 
     rules: [ 
     { 
      test: /\.tsx$/, 
      loaders: [ 
      { 
       loader: 'awesome-typescript-loader', 
       options: { configFileName: 'tsconfig.json' } 
      } , 'angular2-template-loader' 
      ] 
     }, 
     { 
      test: /\.css$/, 
      use: ExtractTextPlugin.extract({use: 'css-loader'}) 
     }, 
     { 
      test: /\.(jpe?g|png|gif|svg)$/i, 
      use: ['url-loader?limit=10000', 'img-loader'] 
     }, 
     { 
      test: /\.(eot|woff2?|ttf)$/i, 
      use: 'url-loader' 
     } 
     ] 
    }, 
    resolve: { 
    extensions: [".tsx", ".ts", ".js"] 
    }, 
    plugins: [ 
    new ExtractTextPlugin("public/styles.css"), 
    ], 
    output: { 
    filename: "public/bundle.js" 
    } 
} 

はここtsconfig.jsonです:

{ 
    "compilerOptions": { 
    "target": "es5", 
    "module": "commonjs", 
    "moduleResolution": "node", 
    "sourceMap": true, 
    "emitDecoratorMetadata": true, 
    "experimentalDecorators": true, 
    "lib": [ "es2015", "dom" ], 
    "noImplicitAny": true, 
    "suppressImplicitAnyIndexErrors": true, 
    "rootDir": "src/ts" 
    }, 
    "angularCompilerOptions": { 
    "genDir": "public/dist/js" 
    }, 
    "exclude": [ 
    "node_modules", 
    "**/*-aot.ts" 
    ], 
    "filesGlob": [ 
    "src/ts/**/*.ts" 
    ] 
} 
それはmain.ts.を通じてapp.module.tsために取得

答えて

0

あなたのファイルにはtsの拡張が含まれていますが、ウェブパックの設定のルールは内線番号tsxと一致しています。両方の拡張機能を処理するには、/\.tsx$\のパターンを/\.tsx?$\に変更します。

{ 
     test: /\.tsx?$/, 
     loaders: [ 
     { 
      loader: 'awesome-typescript-loader', 
      options: { configFileName: 'tsconfig.json' } 
     } , 'angular2-template-loader' 
     ] 
    } 
+0

それを解決しました。別のtsファイルで '記述'に別のエラーが発生しました:TS2304:名前 '記述'が見つかりません。私はこのプロジェクトに取り組む前にtscを得ることができたので、私は何が欠けているのか分かりません。 –

+0

ジャスミンライブラリが見つからないか、正しくインポートされていないようです。しかし、これはまったく異なるエラーです。この問題を解決し、解を見つけられない場合に備えて 'describe'問題の適切な質問を投稿できますか? –

関連する問題