Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
jaywcjlove committed Jun 14, 2018
1 parent 3e2ec82 commit fec0702
Showing 1 changed file with 54 additions and 0 deletions.
54 changes: 54 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,60 @@ module.exports = function (webpackConf, devServer) {
}
```

### Rules 配置修改

修改替换其中的 `Rules`,这里有 [默认Webpack配置](./conf),你可以根据默认配置进行替换和删除,好复杂哦。

```js
module.exports = function (webpackConf, devServer) {
if (webpackConf) {
webpackConf.module.rules.map((item) => {
if (item.oneOf) {
item = item.oneOf.map((childItem) => {
if (String(/\.(css|less)$/) === String(childItem.test)) {
childItem.use = childItem.use.map((_childItem) => {
if (_childItem.loader === require.resolve('css-loader')) {
// 这里将 css-loader 配置替换了重新配置
_childItem = {
loader: require.resolve('css-loader'),
options: {
root: '.',
modules: true,
// minimize: true,
localIdentName: '[local]',
importLoaders: 1,
getLocalIdent: (context, localIdentName, localName) => {
// 过滤 uiw 组件库,因为 modules=true 参数,会将 className替换成Hash,导致uiw样式无法加载
const hash = loaderUtils.getHashDigest(context.resourcePath + localIdentName, 'md5', 'base64', 5);
const uiwpath = path.join(process.cwd(), 'node_modules', 'uiw');
if ((new RegExp(`^${uiwpath}`)).test(context.resourcePath)) {
return localName;
}
return localName + hash;
},
},
}
}
return _childItem;
});
}
return childItem;
});
}
return item;
});

if (webpackConf.mode === 'development') {
// 开发模式下更改的 webpack 配置
}
if (webpackConf.mode === 'production') {
// 生产模式下更改的 webpack 配置
}
return webpackConf
};
}
```

## Mock API

在项目根目录添加 `.kktmock.js` 文件,再在文件中添加需要模拟的API,相关文档在这里[webpack-api-mocker](https://github.com/jaywcjlove/webpack-api-mocker),下面来个实例:
Expand Down

0 comments on commit fec0702

Please sign in to comment.