webpack config:
{
module: {
loaders: [
{test: /\.json$/, loader: 'json'},
{test: /\.ts$/, loader: 'ts-loader'}
]
},
externals: {
THREE: 'THREE'
}
}
my directory:
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'.
Don't use import. See the section in the README on loading assets and https://github.com/TypeStrong/ts-loader/issues/30#issuecomment-128456710
.json can be imported when I using babel-loader so I just simply think ts-loader will be the same.
#30 (comment) work for me.
thank you very much.
@xosuperpig Using import is specifically a TypeScript feature to import type information. When you use const, let or var it will work just like babel does.
Most helpful comment
.json can be imported when I using babel-loader so I just simply think ts-loader will be the same.
#30 (comment) work for me.
thank you very much.