Skip to content

Commit

Permalink
Fixes #147 - Adds support for F5 bundling in Playground.
Browse files Browse the repository at this point in the history
  • Loading branch information
rozele committed May 25, 2016
1 parent 58c65bc commit 2830484
Show file tree
Hide file tree
Showing 9 changed files with 180 additions and 25 deletions.
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -73,4 +73,7 @@ packages/
#Other files
*.DotSettings
.vs/
*project.lock.json
*project.lock.json

#JavaScript files
*.jsbundle
9 changes: 9 additions & 0 deletions Bundle.targets
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Target Name="DoBundle">
<Message Text="Installing react-native node module..." />
<Exec Command="npm install" />
<Message Text="Bundling the entry file..." />
<Exec Command="react-native bundle --entry-file=index.ios.js --bundle-output=main.jsbundle" />
</Target>
</Project>
2 changes: 1 addition & 1 deletion Playground/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public App()
this.Resuming += OnResuming;

_reactPage = new ReactPage(
"ms-appx:///Resources/main.dev.jsbundle",
"ms-appx:///main.jsbundle",
"ReactRoot",
new[] { new MainReactPackage() }.ToList(),
() => { /* TODO: back button handling */ });
Expand Down
51 changes: 46 additions & 5 deletions Playground/Playground.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -87,17 +87,56 @@
<Prefer32Bit>true</Prefer32Bit>
<UseDotNetNativeToolchain>true</UseDotNetNativeToolchain>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Bundle|x86'">
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\x86\Bundle\</OutputPath>
<DefineConstants>DEBUG;TRACE;NETFX_CORE;WINDOWS_UWP;CODE_ANALYSIS</DefineConstants>
<NoWarn>;2008</NoWarn>
<NoStdLib>true</NoStdLib>
<DebugType>full</DebugType>
<PlatformTarget>x86</PlatformTarget>
<UseVSHostingProcess>false</UseVSHostingProcess>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
<Prefer32Bit>true</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Bundle|ARM'">
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\ARM\Bundle\</OutputPath>
<DefineConstants>DEBUG;TRACE;NETFX_CORE;WINDOWS_UWP;CODE_ANALYSIS</DefineConstants>
<NoWarn>;2008</NoWarn>
<NoStdLib>true</NoStdLib>
<DebugType>full</DebugType>
<PlatformTarget>ARM</PlatformTarget>
<UseVSHostingProcess>false</UseVSHostingProcess>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
<Prefer32Bit>true</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Bundle|x64'">
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\x64\Bundle\</OutputPath>
<DefineConstants>DEBUG;TRACE;NETFX_CORE;WINDOWS_UWP;CODE_ANALYSIS</DefineConstants>
<NoWarn>;2008</NoWarn>
<NoStdLib>true</NoStdLib>
<DebugType>full</DebugType>
<PlatformTarget>x64</PlatformTarget>
<UseVSHostingProcess>false</UseVSHostingProcess>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
<Prefer32Bit>true</Prefer32Bit>
</PropertyGroup>
<ItemGroup>
<!-- A reference to the entire .Net Framework and Windows SDK are automatically included -->
<Content Include="ApplicationInsights.config">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<None Include="project.json" />
<Content Include="Resources\main.jsbundle">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
<Content Include="main.jsbundle">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="Resources\main.dev.jsbundle">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
<None Include="project.json" />
<Content Include="index.ios.js">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>
<ItemGroup>
Expand Down Expand Up @@ -144,6 +183,8 @@
<VisualStudioVersion>14.0</VisualStudioVersion>
</PropertyGroup>
<Import Project="$(MSBuildExtensionsPath)\Microsoft\WindowsXaml\v$(VisualStudioVersion)\Microsoft.Windows.UI.Xaml.CSharp.targets" />
<Import Project="..\Bundle.targets" />
<Target Name="BeforeBuild" DependsOnTargets="DoBundle" Condition=" '$(Configuration)' == 'Bundle' " />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
Expand Down
18 changes: 0 additions & 18 deletions Playground/Resources/main.jsbundle

This file was deleted.

62 changes: 62 additions & 0 deletions Playground/index.ios.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
'use strict';

const React = require('react-native');
const styles={
views:{
flexDirection: 'column'
},
images: {
height:200,
width:250,
borderWidth: 5,
borderColor: '#f099f0',
borderRadius: 10
},
textInput: {
height: 40,
borderWidth: 5,
borderColor: '#015d87'
},
longTextInput: {
height: 80,
borderWidth: 3,
borderColor: '#ccc'
}
};

var {AppRegistry, View, Text, TextInput, Image } = React;

var ReactRoot = React.createClass({

getInitialState: function(){
var text = "You can see me!";
var longText = "This is such a long text that it needs to go into a new lineThis is such a long text that it needs to go into a new lineThis is such a long text that it needs to go into a new lineThis is such a long text that it needs to go into a new lineThis is such a long text that it needs to go into a new line";

return {value: text,
longText: longText};
},

render: function() {
let imageURL = "http://facebook.github.io/react-native/img/opengraph.png?2";

return (
<View>
<View style={styles.views}>
<Text>Hello World!</Text>
{(this.state && this.state.value)
? <TextInput value={this.state.value} style={styles.textInput}></TextInput>
: undefined}

{(this.state && this.state.longText)
? <TextInput value={this.state.longText} multiline={true} style={styles.longTextInput}></TextInput>
: undefined}
</View>
<View style={styles.views}>
<Image source={{uri: 'http://facebook.github.io/origami/public/images/blog-hero.jpg?r=1'}} style={styles.images}/>
</View>
</View>
);
}
});

AppRegistry.registerComponent('ReactRoot', () => ReactRoot);
11 changes: 11 additions & 0 deletions Playground/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"name": "Playground",
"version": "0.0.1",
"private": true,
"scripts": {
"start": "node node_modules/react-native/local-cli/cli.js start"
},
"dependencies": {
"react-native": "^0.19.0"
}
}
30 changes: 30 additions & 0 deletions ReactNative.sln
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ReactNative.Tests", "ReactN
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Bundle|Any CPU = Bundle|Any CPU
Bundle|ARM = Bundle|ARM
Bundle|x64 = Bundle|x64
Bundle|x86 = Bundle|x86
Debug|Any CPU = Debug|Any CPU
Debug|ARM = Debug|ARM
Debug|x64 = Debug|x64
Expand All @@ -21,6 +25,14 @@ Global
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{C7673AD5-E3AA-468C-A5FD-FA38154E205C}.Bundle|Any CPU.ActiveCfg = Debug|Any CPU
{C7673AD5-E3AA-468C-A5FD-FA38154E205C}.Bundle|Any CPU.Build.0 = Debug|Any CPU
{C7673AD5-E3AA-468C-A5FD-FA38154E205C}.Bundle|ARM.ActiveCfg = Debug|ARM
{C7673AD5-E3AA-468C-A5FD-FA38154E205C}.Bundle|ARM.Build.0 = Debug|ARM
{C7673AD5-E3AA-468C-A5FD-FA38154E205C}.Bundle|x64.ActiveCfg = Debug|x64
{C7673AD5-E3AA-468C-A5FD-FA38154E205C}.Bundle|x64.Build.0 = Debug|x64
{C7673AD5-E3AA-468C-A5FD-FA38154E205C}.Bundle|x86.ActiveCfg = Debug|x86
{C7673AD5-E3AA-468C-A5FD-FA38154E205C}.Bundle|x86.Build.0 = Debug|x86
{C7673AD5-E3AA-468C-A5FD-FA38154E205C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{C7673AD5-E3AA-468C-A5FD-FA38154E205C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C7673AD5-E3AA-468C-A5FD-FA38154E205C}.Debug|ARM.ActiveCfg = Debug|ARM
Expand All @@ -37,6 +49,16 @@ Global
{C7673AD5-E3AA-468C-A5FD-FA38154E205C}.Release|x64.Build.0 = Release|x64
{C7673AD5-E3AA-468C-A5FD-FA38154E205C}.Release|x86.ActiveCfg = Release|x86
{C7673AD5-E3AA-468C-A5FD-FA38154E205C}.Release|x86.Build.0 = Release|x86
{D52267B5-396F-424A-BB26-C9E750032846}.Bundle|Any CPU.ActiveCfg = Debug|x86
{D52267B5-396F-424A-BB26-C9E750032846}.Bundle|ARM.ActiveCfg = Debug|ARM
{D52267B5-396F-424A-BB26-C9E750032846}.Bundle|ARM.Build.0 = Debug|ARM
{D52267B5-396F-424A-BB26-C9E750032846}.Bundle|ARM.Deploy.0 = Debug|ARM
{D52267B5-396F-424A-BB26-C9E750032846}.Bundle|x64.ActiveCfg = Debug|x64
{D52267B5-396F-424A-BB26-C9E750032846}.Bundle|x64.Build.0 = Debug|x64
{D52267B5-396F-424A-BB26-C9E750032846}.Bundle|x64.Deploy.0 = Debug|x64
{D52267B5-396F-424A-BB26-C9E750032846}.Bundle|x86.ActiveCfg = Bundle|x86
{D52267B5-396F-424A-BB26-C9E750032846}.Bundle|x86.Build.0 = Bundle|x86
{D52267B5-396F-424A-BB26-C9E750032846}.Bundle|x86.Deploy.0 = Bundle|x86
{D52267B5-396F-424A-BB26-C9E750032846}.Debug|Any CPU.ActiveCfg = Debug|x86
{D52267B5-396F-424A-BB26-C9E750032846}.Debug|ARM.ActiveCfg = Debug|ARM
{D52267B5-396F-424A-BB26-C9E750032846}.Debug|ARM.Build.0 = Debug|ARM
Expand All @@ -57,6 +79,14 @@ Global
{D52267B5-396F-424A-BB26-C9E750032846}.Release|x86.ActiveCfg = Release|x86
{D52267B5-396F-424A-BB26-C9E750032846}.Release|x86.Build.0 = Release|x86
{D52267B5-396F-424A-BB26-C9E750032846}.Release|x86.Deploy.0 = Release|x86
{5AC8108B-1C39-4C4A-8653-DBBE4ECCE691}.Bundle|Any CPU.ActiveCfg = Debug|x86
{5AC8108B-1C39-4C4A-8653-DBBE4ECCE691}.Bundle|ARM.ActiveCfg = Debug|ARM
{5AC8108B-1C39-4C4A-8653-DBBE4ECCE691}.Bundle|ARM.Build.0 = Debug|ARM
{5AC8108B-1C39-4C4A-8653-DBBE4ECCE691}.Bundle|ARM.Deploy.0 = Debug|ARM
{5AC8108B-1C39-4C4A-8653-DBBE4ECCE691}.Bundle|x64.ActiveCfg = Debug|x64
{5AC8108B-1C39-4C4A-8653-DBBE4ECCE691}.Bundle|x64.Build.0 = Debug|x64
{5AC8108B-1C39-4C4A-8653-DBBE4ECCE691}.Bundle|x64.Deploy.0 = Debug|x64
{5AC8108B-1C39-4C4A-8653-DBBE4ECCE691}.Bundle|x86.ActiveCfg = Debug|x86
{5AC8108B-1C39-4C4A-8653-DBBE4ECCE691}.Debug|Any CPU.ActiveCfg = Debug|x86
{5AC8108B-1C39-4C4A-8653-DBBE4ECCE691}.Debug|ARM.ActiveCfg = Debug|ARM
{5AC8108B-1C39-4C4A-8653-DBBE4ECCE691}.Debug|ARM.Build.0 = Debug|ARM
Expand Down
17 changes: 17 additions & 0 deletions packager/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
## Using React-Native's CLI to package a Java Script Asset Bundle

React Native is distributed as two npm packages, `react-native-cli` and `react-native`. The first one is a lightweight package that should be installed globally (`npm install -g react-native-cli`), while the second one contains the actual React Native framework code and is installed locally into your project when you run `react-native init`.

`react-native init` is a CLI utility that stands up a React Native project environment for both Android and iOS. The React Native Windows team will add Visual Studio support for UWP builds.

### Creating a Javascript Bundle File

Run this to setup react native CLI using Git Bash. Please make sure you're running [Node v4.2.3](https://nodejs.org/en/download/). You'll also have to install Python version [2.7](https://www.python.org/downloads/release/python-2710/). Please remember to update your %PATH% envinorment variable to include the python directory. You will need to restart your computer after Python is installed.

$ npm install -g react-native-cli
$ cd {REACT_NATIVE_CWD}/windows-packager
$ npm install

Your bundles entry point file(<entry-file>) needs to be named as either index.ios.js or index.android.js. We have an open issue to enhance RN to support index.windows.js named files.

$ react-native bundle --dev false --entry-file <entry-file> --bundle-output <main.jsbundle>

0 comments on commit 2830484

Please sign in to comment.