preboot/angular-webpack

Exclude a folder from at-loader

Closed this issue · 4 comments

I have a folder at the root of the project with some .ts files that are not part of the project. They are just there as supporting files for something else.

The awesome-typescript-loader picks them up and registers them as errors:

[at-loader] Checking finished with 8 errors

However when I try to exclude that folder ('my-folder') in webpack.config.js in the rules array for .ts files as such:

rules : [
  // Support for .ts files.
    {
         test : /\.ts$/,
         loaders : ['awesome-typescript-loader?' + atlOptions, 'angular2-template-loader', '@angularclass/hmr-loader', 'angular2-router-loader'],
         exclude : [isTest ? /\.(e2e)\.ts$/ : /\.(spec|e2e)\.ts$/, /node_modules\/(?!(ng2-.+))/,/my-folder/]
   },

Having /my-folder/ in the exclude property doesn't make any difference in there. Still get the same error.

Is this the right place to exclude a folder?

Also tried adding an exclude property in the tsconfig.json file but then it came back with 4K errors because all of a sudden it started including everything in the node_modules folder.

not sure about the webpack exclude, you can specify fileGlobs in your tsconfig.

{
  "filesGlob": [
    "**/*.ts",
    "!node_modules/**/*"
    "!my-folder/**/*"
  ]
}

Thanks for the quick response @strictd.

The filesGlob didn't make any difference though. Still getting the same error.

So I updated the awesome-typescript-loader to 3.0.0 beta and got the same issue on my mobile directory. The solution was to add it to my tsconfig.json excludes with /**/*

  "exclude": [
    "node_modules",
    "**/*-aot.ts",
    "src/mobile/**/*"
  ],

That worked @strictd.

Thanks Gary.