the newcomer, in the process of building according to the steps on the Internet, the following error occurred:
paste the configuration file about less code:
/ / webpack.config.dev.js
{
test: [/\.css$/, /\.less$/],
use: [
require.resolve("style-loader"),
{
loader: require.resolve("css-loader"),
options: {
importLoaders: 1,
},
},
{
loader: require.resolve("postcss-loader"),
options: {
// Necessary for external CSS imports to work
// https://github.com/facebookincubator/create-react-app/issues/2677
ident: "postcss",
plugins: () => [
require("postcss-flexbugs-fixes"),
autoprefixer({
browsers: [
">1%",
"last 4 versions",
"Firefox ESR",
"not ie < 9", // React doesn"t support IE8 anyway
],
flexbox: "no-2009",
}),
],
},
},
{
loader: require.resolve("less-loader"), // compiles Less to CSS
}
],
},
/ / webpack.config.prod.js
{
// modify
test: /\.(css|less)$/,
loader: ExtractTextPlugin.extract(
Object.assign(
{
fallback: {
loader: require.resolve("style-loader"),
options: {
hmr: false,
},
},
use: [
{
loader: require.resolve("css-loader"),
options: {
importLoaders: 1,
minimize: true,
sourceMap: shouldUseSourceMap,
},
},
{
loader: require.resolve("postcss-loader"),
options: {
// Necessary for external CSS imports to work
// https://github.com/facebookincubator/create-react-app/issues/2677
ident: "postcss",
plugins: () => [
require("postcss-flexbugs-fixes"),
autoprefixer({
browsers: [
">1%",
"last 4 versions",
"Firefox ESR",
"not ie < 9", // React doesn"t support IE8 anyway
],
flexbox: "no-2009",
}),
],
},
},
{
//add
loader: require.resolve("less-loader"),
}
],
},
extractTextPluginOptions
)
),
// Note: this won"t work without `new ExtractTextPlugin()` in `plugins`.
}
/ / index.js
import React from "react";
import ReactDOM from "react-dom";
// import { Router } from "react-router-dom";
import CRouter from "./routers/routeMap";
import { AppContainer } from "react-hot-loader";
import { Provider } from "react-redux";
import { createStore } from "redux";
import registerServiceWorker from "./registerServiceWorker";
import SideCustom from "./containers/side/SiderCustom";
import HeadContain from "./containers/header/header";
import indexReducer from "./reducers/index";
import App from "./App";
import "antd/dist/antd.css";
import "./index.css";