Webpack resolve.alias does not work with typescript? -
i try shorten imports in typescript
from import {hello} "./components/hello";
to import {hello} "hello";
for found out can use resolve.alias
in webpack configured part following
resolve: { root: path.resolve(__dirname), alias: { hello: "src/components/hello" }, extensions: ["", ".ts", ".tsx", ".js"] },
webpack builds, , output bundle.js works. typescript's intellisense complain cannot find module
so question whether or not webpack's resolve.alias works typescript?
i found following issue there's no answer it.
if you're using ts-loader
, you'll have syhchronize webpack alias
settings paths
setting in tsconfig.json
.
{ "compileroptions": { "baseurl": "./", "paths": { "hello": ["src/components/hello"] } } }
if you're using awesome-typescript-loader
, webpack can figure out automatically paths
setting in tsconfig.json
, per the status on issue repo. way, don't need duplicate same information in webpack alias
field.
Comments
Post a Comment