我在webpack.config中为material-ui定义了外部
module.exports = [{ entry: ... output:... externals: { react: { commonjs: "react", commonjs2: "react" }, "material-ui": { commonjs: "material-ui", commonjs2: "material-ui" } }, module: ... }];
仍然它给错误像-
无法解析模块'material-ui / IconButton'......
在我的入门js文件中,我有
import React, {Component} from "react"; import IconButton from "material-ui/IconButton"; ..... .....
VISHAL DAGA.. 5
好的,我解决了。外部期望完整的路径。
所以,
import {IconButton} from "material-ui"
要么
externals: { "material-ui/IconButton": { commonjs: "material-ui/IconButton", ... } }
将工作。当然,这里的第二种选择是不合理的
好的,我解决了。外部期望完整的路径。
所以,
import {IconButton} from "material-ui"
要么
externals: { "material-ui/IconButton": { commonjs: "material-ui/IconButton", ... } }
将工作。当然,这里的第二种选择是不合理的