无法解析“ ../../theme.config”

时间:2019-06-21 15:55:42

标签: reactjs webpack

我有一个这样的项目结构:

├── public
│   └── index.html
├── README.md
├── src
│   ├── App.js
│   ├── common
│   │   ├── actions
│   │   ├── api
│   │   ├── constants
│   │   ├── reducers
│   │   ├── sagas
│   │   ├── selects
│   │   ├── store
│   │   └── utils
│   ├── components
│   ├── containers
│   ├── index.js
│   └── styles
│       ├── site
│       ├── style.less
│       ├── theme.config
│       ├── theme.less
│       └── themes
├── webpack.config.js

在webpack中,我有别名:

resolve: {
    alias: {
        '../../theme.config$': path.join(__dirname, '/styles/theme.config')
    }
}

但别名不起作用:

@import (multiple) '../../theme.config'; ^ Can't resolve '../../theme.config'

我不知道我做错了什么。 也许我为别名做的配置错误?

1 个答案:

答案 0 :(得分:1)

您的Webpack配置在src之外,因此您的别名不正确:

resolve: {
    alias: {
        '../../theme.config$': path.join(__dirname, 'src/styles/theme.config')
    }
}
相关问题