在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
1、webpack.config.js resolve: { extensions: ["ts", "tsx", "js", "jsx"], alias: { images: path.resolve(__dirname, 'src/images/' )} } 2、tsconfig.json { "compilerOptions": { "baseUrl": ".", "paths: { "images/*": ["src/images/*"] } } } 3、declare images.d.ts declare module '*.png' declare module '*.gif' declare module '*.jpeg' declare module '*.jpg' 4、webpack.config.js { test: /\.(gif|jpg|png|woff|svg|eot|ttf|otf|woff2)\??.*$/, use: [ { loader: 'file-loader', options: { name: '[path][name].[ext]' } } ] } 5、import * as Img from "./path/to/image.png"; |
请发表评论