How to require/import .less file in typescript file

Viewed 9794

I am trying to import a .less file in .ts file but I am not able to do that. I am using webpack2 as bundler & webstorm IDE

Here snippet for less loader in a webpack.config.js file

{
  test: /\.less$/,      //less loader
  loader: ExtractTextPlugin.extract({
    fallbackLoader: 'style-loader',
    //loader: 'css-loader!less-loader'
    loader: 'raw-loader!less-loader'
  })
}, {
  test: /\.ts$/,    //typescript loader
  //include: path.resolve(__dirname, "ts-src"),
  include: path.resolve(__dirname, "js"),
  loader: "ts-loader"
}
//rest of code
resolve: {
  extensions: [".webpack.js", ".web.js", ".ts", ".tsx", ".js", ".css", ".less"],
}

As mentioned in link I tried by creating a global.d.ts file but no luck

Also i tried to require the file in the main.ts but in this case I am not seeing any option to requires a less file. My question is how to load a .less file in a typescript files

[Project strucure

2 Answers
Related