Skip to content

Commit

Permalink
fix: compact react plugin targets is undefined (#490)
Browse files Browse the repository at this point in the history
  • Loading branch information
SoloJiang authored Nov 18, 2020
1 parent 6947124 commit 98426dd
Show file tree
Hide file tree
Showing 14 changed files with 122 additions and 17 deletions.
2 changes: 2 additions & 0 deletions examples/basic-compat-react/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Basic compact with react

5 changes: 5 additions & 0 deletions examples/basic-compat-react/build.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"targets": ["web"],
"plugins": ["build-plugin-rax-compat-react"],
"store": false
}
22 changes: 22 additions & 0 deletions examples/basic-compat-react/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"name": "with-rax",
"description": "rax example",
"dependencies": {
"rax": "^1.1.0",
"rax-document": "^0.1.0",
"rax-image": "^2.0.0",
"rax-link": "^1.0.1",
"rax-text": "^1.0.0",
"rax-view": "^1.0.0"
},
"devDependencies": {
"@types/rax": "^1.0.0"
},
"scripts": {
"start": "rax-app start",
"build": "rax-app build"
},
"engines": {
"node": ">=8.0.0"
}
}
11 changes: 11 additions & 0 deletions examples/basic-compat-react/src/app.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"routes": [
{
"path": "/",
"source": "pages/Home/index"
}
],
"window": {
"title": "Rax App"
}
}
28 changes: 28 additions & 0 deletions examples/basic-compat-react/src/app.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import { createElement } from 'rax';
import { runApp } from 'rax-app';

runApp({
router: {
type: 'browser',
},
app: {
// ErrorBoundary
errorBoundary: true,

// 生命周期
onShow() {
console.log('app show...');
},
onHide() {
console.log('app hide...');
},

// 获取初始数据
getInitialData: async () => {
return {
a: 1,
b: 2,
};
},
},
});
22 changes: 22 additions & 0 deletions examples/basic-compat-react/src/document/index.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { createElement } from 'rax';
import { Root, Style, Script, Data } from 'rax-document';

function Document(props) {
return (
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1,minimum-scale=1,user-scalable=no,viewport-fit=cover" />
<title>@ali/demo-app</title>
<Style />
</head>
<body>
{/* root container */}
<Root />
<Data />
<Script />
</body>
</html>
);
}
export default Document;
16 changes: 16 additions & 0 deletions examples/basic-compat-react/src/pages/Home/index.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
.home {
align-items: center;
margin-top: 200rpx;
}

.title {
font-size: 35rpx;
font-weight: bold;
margin: 20rpx 0;
}

.info {
font-size: 36rpx;
margin: 8rpx 0;
color: #555;
}
10 changes: 10 additions & 0 deletions examples/basic-compat-react/src/pages/Home/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import React from 'react';

import './index.css';

export default function Home() {
return (
React.createElement('div', {}, [123])
);
}

2 changes: 0 additions & 2 deletions examples/with-rax-miniapp-compile/README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
# with rax miniapp compile

https://github.com/ice-lab/icejs/tree/master/examples
2 changes: 0 additions & 2 deletions examples/with-rax-mpa/README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
# with rax mpa

https://github.com/ice-lab/icejs/tree/master/examples
2 changes: 0 additions & 2 deletions examples/with-rax-store/README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
# with rax

https://github.com/ice-lab/icejs/tree/master/examples
2 changes: 0 additions & 2 deletions examples/with-rax/README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
# with rax

https://github.com/ice-lab/icejs/tree/master/examples
2 changes: 1 addition & 1 deletion examples/with-rax/build.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"targets": ["kraken"]
"targets": ["web", "weex", "kraken", "miniapp", "wechat-miniprogram"]
}
13 changes: 5 additions & 8 deletions packages/plugin-rax-compat-react/src/index.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
module.exports = ({ onGetWebpackConfig, getValue }) => {
const targets = getValue('targets');
targets.forEach((target) => {
onGetWebpackConfig(target, (config) => {
config.resolve.alias
.set('react', 'rax/lib/compat')
.set('react-dom', 'rax-dom');
});
module.exports = ({ onGetWebpackConfig }) => {
onGetWebpackConfig((config) => {
config.resolve.alias
.set('react', 'rax/lib/compat')
.set('react-dom', 'rax-dom');
});
};

0 comments on commit 98426dd

Please sign in to comment.