mirror of
https://github.com/aspnet/JavaScriptServices.git
synced 2025-12-23 10:08:57 +00:00
Update ReactSpa to React Hot Loader 3. Remove babel dependency.
This commit is contained in:
@@ -1,3 +0,0 @@
|
|||||||
{
|
|
||||||
"presets": ["es2015", "react"]
|
|
||||||
}
|
|
||||||
@@ -2,12 +2,28 @@ import './css/site.css';
|
|||||||
import 'bootstrap';
|
import 'bootstrap';
|
||||||
import * as React from 'react';
|
import * as React from 'react';
|
||||||
import * as ReactDOM from 'react-dom';
|
import * as ReactDOM from 'react-dom';
|
||||||
|
import { AppContainer } from 'react-hot-loader';
|
||||||
import { BrowserRouter } from 'react-router-dom';
|
import { BrowserRouter } from 'react-router-dom';
|
||||||
import routes from './routes';
|
import * as RoutesModule from './routes';
|
||||||
|
let routes = RoutesModule.routes;
|
||||||
|
|
||||||
// This code starts up the React app when it runs in a browser. It sets up the routing configuration
|
function renderApp() {
|
||||||
// and injects the app into a DOM element.
|
// This code starts up the React app when it runs in a browser. It sets up the routing
|
||||||
|
// configuration and injects the app into a DOM element.
|
||||||
ReactDOM.render(
|
ReactDOM.render(
|
||||||
<BrowserRouter children={ routes } />,
|
<AppContainer>
|
||||||
|
<BrowserRouter children={ routes } />
|
||||||
|
</AppContainer>,
|
||||||
document.getElementById('react-app')
|
document.getElementById('react-app')
|
||||||
);
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
renderApp();
|
||||||
|
|
||||||
|
// Allow Hot Module Replacement
|
||||||
|
if (module.hot) {
|
||||||
|
module.hot.accept('./routes', () => {
|
||||||
|
routes = require<typeof RoutesModule>('./routes').routes;
|
||||||
|
renderApp();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|||||||
@@ -5,14 +5,8 @@ import { Home } from './components/Home';
|
|||||||
import { FetchData } from './components/FetchData';
|
import { FetchData } from './components/FetchData';
|
||||||
import { Counter } from './components/Counter';
|
import { Counter } from './components/Counter';
|
||||||
|
|
||||||
export default <Layout>
|
export const routes = <Layout>
|
||||||
<Route exact path='/' component={ Home } />
|
<Route exact path='/' component={ Home } />
|
||||||
<Route path='/counter' component={ Counter } />
|
<Route path='/counter' component={ Counter } />
|
||||||
<Route path='/fetchdata' component={ FetchData } />
|
<Route path='/fetchdata' component={ FetchData } />
|
||||||
</Layout>;
|
</Layout>;
|
||||||
|
|
||||||
// Allow Hot Module Reloading
|
|
||||||
declare var module: any;
|
|
||||||
if (module.hot) {
|
|
||||||
module.hot.accept();
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -6,13 +6,10 @@
|
|||||||
"@types/react": "^0.14.38",
|
"@types/react": "^0.14.38",
|
||||||
"@types/react-dom": "^0.14.17",
|
"@types/react-dom": "^0.14.17",
|
||||||
"@types/react-router": "^2.0.38",
|
"@types/react-router": "^2.0.38",
|
||||||
|
"@types/webpack-env": "^1.13.0",
|
||||||
"aspnet-webpack": "^1.0.27",
|
"aspnet-webpack": "^1.0.27",
|
||||||
"aspnet-webpack-react": "^1.0.4",
|
"aspnet-webpack-react": "^2.0.0",
|
||||||
"awesome-typescript-loader": "^3.0.0",
|
"awesome-typescript-loader": "^3.0.0",
|
||||||
"babel-core": "^6.17.0",
|
|
||||||
"babel-loader": "^6.2.5",
|
|
||||||
"babel-preset-es2015": "^6.16.0",
|
|
||||||
"babel-preset-react": "^6.16.0",
|
|
||||||
"bootstrap": "^3.3.6",
|
"bootstrap": "^3.3.6",
|
||||||
"css-loader": "^0.25.0",
|
"css-loader": "^0.25.0",
|
||||||
"event-source-polyfill": "^0.0.7",
|
"event-source-polyfill": "^0.0.7",
|
||||||
@@ -23,6 +20,7 @@
|
|||||||
"json-loader": "^0.5.4",
|
"json-loader": "^0.5.4",
|
||||||
"react": "~15.4.0",
|
"react": "~15.4.0",
|
||||||
"react-dom": "~15.4.0",
|
"react-dom": "~15.4.0",
|
||||||
|
"react-hot-loader": "3.0.0-beta.7",
|
||||||
"react-router-dom": "^4.0.0",
|
"react-router-dom": "^4.0.0",
|
||||||
"style-loader": "^0.13.1",
|
"style-loader": "^0.13.1",
|
||||||
"typescript": "^2.2.1",
|
"typescript": "^2.2.1",
|
||||||
|
|||||||
@@ -2,10 +2,11 @@
|
|||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
"baseUrl": ".",
|
"baseUrl": ".",
|
||||||
"moduleResolution": "node",
|
"moduleResolution": "node",
|
||||||
"target": "es6",
|
"target": "es5",
|
||||||
"jsx": "preserve",
|
"jsx": "react",
|
||||||
"sourceMap": true,
|
"sourceMap": true,
|
||||||
"skipDefaultLibCheck": true,
|
"skipDefaultLibCheck": true,
|
||||||
|
"types": [ "webpack-env" ],
|
||||||
"paths": {
|
"paths": {
|
||||||
// Fix "Duplicate identifier" errors caused by multiple dependencies fetching their own copies of type definitions.
|
// Fix "Duplicate identifier" errors caused by multiple dependencies fetching their own copies of type definitions.
|
||||||
// We tell TypeScript which type definitions module to treat as the canonical one (instead of combining all of them).
|
// We tell TypeScript which type definitions module to treat as the canonical one (instead of combining all of them).
|
||||||
|
|||||||
@@ -17,7 +17,6 @@ module.exports = (env) => {
|
|||||||
},
|
},
|
||||||
module: {
|
module: {
|
||||||
rules: [
|
rules: [
|
||||||
{ test: /\.ts(x?)$/, include: /ClientApp/, use: { loader: 'babel-loader', options: { cacheDirectory: true } } },
|
|
||||||
{ test: /\.tsx?$/, include: /ClientApp/, use: 'awesome-typescript-loader?silent=true' },
|
{ test: /\.tsx?$/, include: /ClientApp/, use: 'awesome-typescript-loader?silent=true' },
|
||||||
{ test: /\.css$/, use: isDevBuild ? ['style-loader', 'css-loader'] : ExtractTextPlugin.extract({ use: 'css-loader?minimize' }) },
|
{ test: /\.css$/, use: isDevBuild ? ['style-loader', 'css-loader'] : ExtractTextPlugin.extract({ use: 'css-loader?minimize' }) },
|
||||||
{ test: /\.(png|jpg|jpeg|gif|svg)$/, use: 'url-loader?limit=25000' }
|
{ test: /\.(png|jpg|jpeg|gif|svg)$/, use: 'url-loader?limit=25000' }
|
||||||
|
|||||||
Reference in New Issue
Block a user