我有这个webpack.config文件:
const path = require('path')
var config = {
entry: './src/index.js',
output: {
path:'/',
filename: 'bundle.js',
},
devServer: {
inline: true,
port: 8080,
historyApiFallback: {
index: 'index.html'
}
},
module: {
loaders: [
{
test: /\.jsx?$/,
exclude: /node_modules/,
loader: 'babel-loader',
query: {
presets: ['es2015', 'react']
}
},
{
test: /\.scss$/,
loaders: ["style", "css", "sass"]
},
]
},
resolve: {
modules: [path.resolve(__dirname, "src"), "node_modules"]
}
}
module.exports = config;
当我想导入样式时,我收到此错误:
未捕捉错误:
找不到模块" ./ style.scss" at webpackMissingModule(bundle.js:77680)at object.defineProperty.value(bundle.js:77680)at webpack_require(bundle.js:20)at object.defineProperty.value(bundle.js:77611)at webpack_require(bundle.js) :20)在Object.defineProperty.value(bundle.js:77047)at at webpack_require(bundle.js:20)at object.defineProperty.value(bundle.js:50608)at webpack_require(bundle.js:20)at Object。 defineProperty.value(bundle.js:50310)
这是组件:
...
import './style.scss';
class Solution extends Component {
render() {
return (
...
)
}
}
export default Solution;
scss文件在同一文件夹中有组件。