在开发一个 Chrome 扩展时,依赖了element-plus
。
想体验按需加载的福利,于是借助了这个 package:unplugin-element-plus/webpack
,引入方式如下
const ElementPlus = require('unplugin-element-plus/webpack').default;
plugins: [
// ...
ElementPlus(),
],
编译时,遇到报错:
Module not found: Error: Can't resolve element-plus/es/components/button/style/css
沿着报错中提供的路径进到包里一看究竟,扩展名并没有 .js
的资源
于是修改了此处:
resolve: {
extensions: ['.ts', '.js', '.vue', '.json', '.mjs'],
// ...
}
添加了.mjs
,至此问题解决。
附
- 部分依赖包版本:
{
"dependencies": {
"element-plus": "^1.2.0-beta.6",
"unplugin-element-plus": "^0.1.3",
"vue": "^3.2.20",
"vue-class-component": "^7.1.0",
"vue-property-decorator": "^8.3.0"
},
"devDependencies": {
"webpack": "^5.65.0",
"webpack-cli": "^4.9.1",
}
}