Ts-loader: Is ts-loader ignoring my tsconfig file?

Created on 22 Mar 2017  路  7Comments  路  Source: TypeStrong/ts-loader

I think ts-loader is ignoring my tsconfig file. In it I have set "traceResolution": true, and "outDir": "./dist/", but none logs for resolutions are displayed and no dist folder is created.
Here is my tsconfig.json

{
  "compilerOptions": {
    "module": "commonjs",
    "target": "es5",
    "sourceMap": true,
    "allowJs": true,
    "typeRoots": [
      "node_modules/@types"
    ],
    "traceResolution": true,
    "outDir": "./dist/",
    "baseUrl": ".",
    "paths": {
      "*": [
        "C:\\strony\\www\\libsJs\\*"
      ]
    }
  },
  "exclude": [
    "node_modules"
  ]
}

And webpack.config.js part:

module: {
        rules: [
            {
                test: /\.css$/i,
                use: ['style-loader', 'css-loader']
            },
            {
                test: /\.ts$/,
                use: [{
                    loader: 'ts-loader',
                }],
            },

both files are in root directory

Most helpful comment

If you are expecting ts-loader to resolve according to your baseUrl and paths section of tsconfig.json I think that will not work out-of-the-box. I've made a webpack plugin that adds that resolving, you can find it here: tsconfig-paths-webpack-plugin

All 7 comments

Did you try

resolve: {
    extensions: [
        '.ts',
        '.tsx',
        '.js',
        '.jsx',
        '.json'
    ],
}

although this might not help with the outDir part.

Yes - have those

Where is your tsconfig.json in relation to your source files - what does your project structure look like?

If you are expecting ts-loader to resolve according to your baseUrl and paths section of tsconfig.json I think that will not work out-of-the-box. I've made a webpack plugin that adds that resolving, you can find it here: tsconfig-paths-webpack-plugin

Thanks for sharing @jonaskello - it's not functionality I use and so I've never paid too much attention to it. That said, it's clearly valued by others. Would you fancy adding something to ts-loader's readme to point people who want that functionality towards your plugin?

@johnnyreilly I actually made #693 just today for that :-). I'll go ahead and do a PR too.

Thanks!

Was this page helpful?
0 / 5 - 0 ratings