Skip to content

how can i load .json in typescript file? #74

@zombieyang

Description

@zombieyang

webpack config:

{
    module: {
        loaders: [
            {test: /\.json$/, loader: 'json'},
            {test: /\.ts$/, loader: 'ts-loader'}
        ]
    },
    externals: {
        THREE: 'THREE'
    }
}

my directory:

  • src
    • entry.ts
    • ball.json

entry.ts:

/// <reference path="../typings/threejs/three.d.ts" />
import ball from './ball.json';

//....

but when i run the webpack, it will report
ERROR in ./src/entry.ts
(5,20): error TS2307: Cannot find module './ball.json'.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions