React +Mock+webpack+antd+less
create-react-app anydream
npm run eject(创建项目之后立即执行)
npm install --save antd
npm install --save babel-plugin-import
npm install less --save
cnpm install less-loader --save
{
test: lessRegex,
exclude: lessModuleRegex,
use: getStyleLoaders(
{
importLoaders: 2,
sourceMap: isEnvProduction && shouldUseSourceMap,
},
'less-loader'
),
// Don't consider CSS imports dead code even if the
// containing package claims to have no side effects.
// Remove this when webpack adds a warning or an error for this.
// See https://github.com/webpack/webpack/issues/6571
sideEffects: true,
},
// Adds support for CSS Modules, but using SASS
// using the extension .module.less or .module.less
{
test: lessModuleRegex,
use: getStyleLoaders(
{
importLoaders: 2,
sourceMap: isEnvProduction && shouldUseSourceMap,
modules: true,
getLocalIdent: getCSSModuleLocalIdent,
},
'less-loader'
),
},
npm install mock webpack-api-mocker --save-dev
module.exports = {
[`GET /user`]: (req, res) => {
return {
data: [123]
};
}
}