Skip to content
This repository has been archived by the owner on Mar 7, 2024. It is now read-only.

Commit

Permalink
feat: configWebpack 新增 addCSSRule 帮助方法
Browse files Browse the repository at this point in the history
  • Loading branch information
yesmeck committed May 19, 2020
1 parent 9021b51 commit aaf6a88
Show file tree
Hide file tree
Showing 18 changed files with 2,271 additions and 16 deletions.
8 changes: 7 additions & 1 deletion docs/guide/config/remax.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,20 @@ _默认值:_ `true`
// remax.config.js

module.exports = {
configWebpack({ config, webpack }) {
configWebpack({ config, webpack, addCSSRule }) {
// config 是的 [webpack-chain](https://github.com/neutrinojs/webpack-chain) Config 对象。
config.plugins.delete('webpackbar'); // 去掉进度条
config.plugin('custom-define').use(webpack.DefinePlugin, [
{
__MOCK__: JSON.stringify(process.env.MOCK),
},
]); // 新增一个 define 插件

// 引用 wxss
addCSSRule({
name: 'wxss',
test: /\.wxss(\?.*)?$/,
});
},
};
```
Expand Down
3 changes: 3 additions & 0 deletions packages/remax-cli/src/__tests__/integration/config.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import * as path from 'path';
import build from './helpers/build';
import getConfig from '../../getConfig';
import { Platform } from '@remax/types';
import runTest from './helpers/runTest';

describe('remax config', () => {
it('override output', () => {
Expand All @@ -21,4 +22,6 @@ describe('remax config', () => {
it('throw error when missing pages config in app.config', async () => {
await expect(build('exception', Platform.ali)).rejects.toThrow('app.config.js|ts 并未配置页面参数');
});

runTest('config-add-css-rule');
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
require('./runtime.js');
(my["webpackJsonp"] = my["webpackJsonp"] || []).push([[1],[
/* 0 */
/***/ (function(module, exports, __webpack_require__) {

module.exports = __webpack_require__(1);


/***/ }),
/* 1 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {

"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony import */ var _remax_runtime__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(2);
/* harmony import */ var _remax_runtime__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_remax_runtime__WEBPACK_IMPORTED_MODULE_0__);
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(3);
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_1__);



var _app = function _app(props) {
return props.children;
};

/* harmony default export */ __webpack_exports__["default"] = (App(Object(_remax_runtime__WEBPACK_IMPORTED_MODULE_0__["createAppConfig"])(_app)));

/***/ }),
/* 2 */
/***/ (function(module, exports) {

module.exports = require("@remax/runtime");

/***/ }),
/* 3 */
/***/ (function(module, exports) {

module.exports = require("react");

/***/ })
],[[0,0]]]);
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
{
"pages": [
"pages/index",
"pages/dont-exist/index",
"pages/classPage"
],
"window": {
"defaultTitle": "Ali App",
"titleBarColor": "#323239"
},
"subPackages": [
{
"root": "packageA",
"pages": [
"pages/index"
]
}
],
"tabBar": {
"textColor": "#ffffff",
"selectedColor": "#000000",
"backgroundColor": "#212121",
"items": [
{
"pagePath": "pages/index/index",
"name": "首页",
"icon": "/assets/images/cat.png",
"activeIcon": "/assets/images/dog.png"
},
{
"pagePath": "packageA/pages/index",
"name": "其他",
"icon": "https://img.com/assets/images/cat.png",
"activeIcon": "/assets/images/dog.png"
}
]
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.b {
background-color: white;
}

Loading

0 comments on commit aaf6a88

Please sign in to comment.