我有一个错误代码。 我认为这个错误是由webpack.config.js引起的。 我查阅了许多资料,但没有得到结果。
ERROR in ./node_modules/bootstrap/dist/css/bootstrap.css
Module parse failed: Unexpected token (7:5)
You may need an appropriate loader to handle this file type.
| */
| /*! normalize.css v3.0.3 | MIT License | github.com/necolas/normalize.css */
| html {
| font-family: sans-serif;
| -webkit-text-size-adjust: 100%;
@ ./index.js 21:0-43
@ multi (webpack)-dev-server/client?http://localhost:8080 ./index.js
我的webpack.config.js文件。我已经在这里做了一些安排,但是我又遇到了一个错误。我该如何解决这个错误?
var webpack = require('webpack');
var path = require('path');
var parentDir = path.join(__dirname, '../');
module.exports = {
entry: [
path.join(parentDir, 'index.js')
],
module: {
loaders: [{
test: /\.(js|jsx)$/,
exclude: /node_modules/,
loader: 'babel-loader'
},{
test: /\.less$/,
loaders: ["style-loader", "css-loder", "less-loader"]
}
]
},
output: {
path: parentDir + '/dist',
filename: 'bundle.js'
},
devServer: {
contentBase: parentDir,
historyApiFallback: true
}
}
像这样的 index.js 文件。
import React from 'react';
import ReactDOM from 'react-dom';
import { Provider } from 'react-redux';
import AppRoutes from './routes';
import store from './store';
import 'bootstrap/dist/css/bootstrap.css';
ReactDOM.render(
<Provider store={store}>
<AppRoutes />
</Provider>,
document.getElementById('app')
)