Skip to content

Commit 0039187

Browse files
Tweak ReactGrid's Webpack config in preparation for use of dev middleware
1 parent 225dfdd commit 0039187

7 files changed

Lines changed: 29 additions & 19 deletions

File tree

samples/react/ReactGrid/.babelrc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
presets: ["es2015", "react"]
3+
}

samples/react/ReactGrid/.gitignore

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
/node_modules/
22
project.lock.json
3-
/wwwroot/bundle.*
4-
/wwwroot/*.svg
5-
/wwwroot/*.css
3+
/wwwroot/dist/
64
/Properties/launchSettings.json

samples/react/ReactGrid/ReactApp/components/CustomPager.jsx

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React from 'react';
1+
import * as React from 'react';
22
import { Link } from 'react-router';
33

44
export class CustomPager extends React.Component {
@@ -7,8 +7,8 @@ export class CustomPager extends React.Component {
77
}
88

99
render() {
10-
var previous = "";
11-
var next = "";
10+
var previous = null;
11+
var next = null;
1212

1313
if(this.props.currentPage > 0){
1414
previous = <div className="btn btn-default"><Link className="previous" to={'/' + (this.props.currentPage)}><i className="glyphicon glyphicon-arrow-left"></i>{this.props.previousText}</Link></div>;
@@ -20,12 +20,12 @@ export class CustomPager extends React.Component {
2020

2121
var options = [];
2222

23-
var startIndex = Math.max(this.props.currentPage - 5, 0);
24-
var endIndex = Math.min(startIndex + 11, this.props.maxPage);
23+
var startIndex = Math.max(this.props.currentPage - 5, 0);
24+
var endIndex = Math.min(startIndex + 11, this.props.maxPage);
2525

26-
if (this.props.maxPage >= 11 && (endIndex - startIndex) <= 10) {
27-
startIndex = endIndex - 11;
28-
}
26+
if (this.props.maxPage >= 11 && (endIndex - startIndex) <= 10) {
27+
startIndex = endIndex - 11;
28+
}
2929

3030
for(var i = startIndex; i < endIndex ; i++){
3131
var selected = this.props.currentPage == i ? "btn-default" : "";
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<div id="react-app" asp-react-prerender-module="ReactApp/components/ReactApp.jsx"></div>
22

33
@section scripts {
4-
<script src="/bundle.js"></script>
4+
<script src="/dist/main.js"></script>
55
}

samples/react/ReactGrid/Views/Shared/_Layout.cshtml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<head>
44
<meta charset="utf-8" />
55
<title>ReactExample</title>
6-
<link rel="stylesheet" href="/main.css" />
6+
<link rel="stylesheet" href="/dist/main.css" />
77
</head>
88
<body>
99
<div class="container">

samples/react/ReactGrid/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "ReactExample",
33
"version": "0.0.0",
44
"dependencies": {
5-
"babel-core": "^6.4.0",
5+
"babel-core": "^6.4.5",
66
"bootstrap": "^3.3.5",
77
"formsy-react": "^0.17.0",
88
"formsy-react-components": "^0.6.3",

samples/react/ReactGrid/webpack.config.js

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,27 @@
1+
var path = require('path');
2+
var webpack = require('webpack');
13
var ExtractTextPlugin = require('extract-text-webpack-plugin');
24

35
module.exports = {
4-
entry: './ReactApp/boot-client.jsx',
5-
output: {
6-
path: './wwwroot',
7-
filename: 'bundle.js'
6+
devtool: 'eval-source-map',
7+
resolve: {
8+
extensions: [ '', '.js', '.jsx' ]
89
},
910
module: {
1011
loaders: [
11-
{ test: /\.jsx?$/, loader: 'babel-loader', exclude: /node_modules/, query: { presets: ['es2015', 'react'] } },
12+
{ test: /\.jsx?$/, loader: 'babel-loader', exclude: /node_modules/ },
1213
{ test: /\.css$/, loader: ExtractTextPlugin.extract('style-loader', 'css-loader') },
1314
{ test: /\.(png|woff|woff2|eot|ttf|svg)$/, loader: 'url-loader?limit=100000' }
1415
]
1516
},
17+
entry: {
18+
main: ['./ReactApp/boot-client.jsx']
19+
},
20+
output: {
21+
path: path.join(__dirname, '/wwwroot/dist'),
22+
filename: '[name].js',
23+
publicPath: '/dist/' // Tells webpack-dev-middleware where to serve the dynamically compiled content from
24+
},
1625
plugins: [
1726
new ExtractTextPlugin('main.css')
1827
]

0 commit comments

Comments
 (0)