Anaïs Saez
Anaïs Saez

Reputation: 1339

webpack error : You may need an appropriate loader to handle this file type

I'm trying to build my server.ts typescipt file for back end, i've just some import , et my app doesn't build.

In my typescript file, I have :

import * as Express from 'express'
import * as Session from 'express-session'
let app = Express()

app.use(Session({
    secret: '2C44-4D44-WppQ38S',
    resave: true,
    saveUninitialized: true
}));

Errors in my node console : enter image description here

This is my webpack config :

 module: {
        loaders: [     
            { test: /\.tsx?$/, loaders: ['babel', 'ts-loader'] },
            { test: /\.css$/, loaders: ['style', 'css-loader'] },
            { test: /\.scss$/, loaders: ['style', 'css-loader?modules&importLoaders=1&localIdentName=[local]-[hash:base64:5]', 'postcss-loader', 'sass'] },
            { test: /\.(png|svg|gif|jpg|jpeg)$/, loaders: [ 'url-loader', 'image-webpack?bypassOnDebug'] },
            { test: /\.(eot|woff|ttf|woff2)$/, loader: "file?name=[name].[ext]" }
        ]
    }

I tried to do

test: /\.(ts|tsx)?$/

But it doesn't work.. Do you have an idea ?

Thank you

Upvotes: 0

Views: 227

Answers (1)

lilezek
lilezek

Reputation: 7374

From your comment (you use webpack 1), you have two options, to either update your webpack version, or use this:

https://github.com/webpack-contrib/json-loader

⚠️ Since webpack >= v2.0.0, importing of JSON files will work by default. You might still want to use this if you use a custom file extension. See the v1.0.0 -> v2.0.0 Migration Guide for more information

Upvotes: 1

Related Questions