I am building basic react application with typescript but I am not able to import CSS file in index.tsx file
I am able to import index.css file following way:
import './index.css';
//this import gives typescript error when running webpack
but not able to import as
import * as Styles from './index.css';
this is my webpack.config.js file
var path = require("path");
var HtmlWebpackPlugin = require('html-webpack-plugin')
var config = {
mode:"none",
entry:"./src/index.tsx",
output:{
path: path.resolve(__dirname,"dist"),
filename: "bundle.js"
},
resolve:{
extensions:[".ts", ".tsx", ".js"]
},
module:{
rules:[
{test:/\.tsx?$/, loader:"awesome-typescript-loader"},
{ test: /\.css$/, include: path.join(__dirname, 'src/'),
loader:"typings-for-css-modules-loader" }
]
},
plugins:[new HtmlWebpackPlugin({
template: './index.html'
})]
};
module.exports = config;
I tried following links before posting but no luck
How to include .css file in .tsx typescript?
How to import css file for into Component .jsx file
https://github.com/parcel-bundler/parcel/issues/616
Thanks in advance
https://github.com/zeit/styled-jsx.tsso might be in your case tslint is not able findindex.css.tsfile and because of this it's throwing error 'module not found'.cssextension not with.css.ts. like: index.css.tsor.tsxso it will throw an error if an import has an unknown file suffix. If you have a webpack config that allows you to import other types of files, you have to tell the TypeScript compiler that these files exist