左右似乎,
如果我使用常规相对路径,代码会转换,但是当我使用resolve.modules
时,我会收到以下错误消息:
You may need an appropriate loader to handle this file type.
| export default class Test {
|
| name = 'Joe';
|
| constructor() {
...
webpack.config:
...
resolve: {
modules: [
path.resolve(__dirname,'resources/assets/app'),
path.resolve('./node_modules')
],
},
module: {
...
应用程序/核心/ Test.js:
export default class Test {
name = 'Joe';
constructor() {
console.log('construct a Test');
}
}
用法:
import Test from 'core/Test';
有谁知道这是一个错误还是我错过了什么?
使用resolve.alias
还尝试使用babel-plugin-transform-class-properties
.babelrc
{
"presets": [
"es2015",
"stage-0",
"react"
],
"plugins": [
"babel-plugin-transform-class-properties",
"react-hot-loader/babel",
"transform-async-to-generator",
"transform-decorators-legacy"
]
}