Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: compact react plugin targets is undefined #490

Merged
merged 1 commit into from
Nov 18, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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');
});
};