1

I am trying to use webpack to package my typescript project but it seems to ignore my loader settings.

Currently I have :

module.exports = {
    mode: "development",
    entry:{
        app: "./words.ts",
    },
    module: {
        rules: [
                  {
                      test: '/\.ts?$/',
                      loader: 'awesome-typescript-loader',
                      exclude: '/node-modules'
                  }
    ]
    },
    resolve: {
    extensions: [ '.tsx', '.ts', '.js' ]
    },

    output:{
    path: __dirname + "/build",
    filename:"[name].js"
    }
}

I know that it is using my webpack.conf file because if I remove it then it complains and it appears to work correctly but what I notice is that it does not matter what I put as the loader, for example if I put "hello" it will still transpile and package my code. I have also noticed that if I remove my tsconfig.json file I get the same result so it is clearly not trying to use it. Is there a default loader setup that I need to override?

Thanks, Daniel.

1
  • There is no default loader for typescript, my suspicious is the regex, test: '/\.ts?$/', try to remove the ? Commented May 14, 2018 at 17:45

1 Answer 1

1

Looks like you are passing a string that contains the regex instead of regex as a test argument.

Try to change it to:

rules: [
  {
    test: /\.tsx?$/, // this suppose to be regex expression.
    loader: 'awesome-typescript-loader',
    exclude: '/node-modules'
  }
]
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.