John 7 éve
szülő
commit
ffbc545c9b
3 módosított fájl, 27 hozzáadás és 24 törlés
  1. 0 1
      src/main.js
  2. 12 9
      tools/start.js
  3. 15 14
      webpack.config.js

+ 0 - 1
src/main.js

@@ -1,6 +1,5 @@
 /* eslint-disable no-underscore-dangle */
 /* eslint-disable no-undef */
-
 import React from 'react'
 import ReactDOM from 'react-dom'
 import createBrowserHistory from 'history/lib/createBrowserHistory'

+ 12 - 9
tools/start.js

@@ -56,15 +56,18 @@ task('start', () => new Promise(resolve => {
 
         // Serve index.html for all unknown requests
         (req, res, next) => {
-          const filename = path.join(bundler.outputPath, 'index.html')
-          bundler.outputFileSystem.readFile(filename, (err, result) => {
-            if (err) {
-              next(err)
-              return
-            }
-            res.setHeader('content-type', 'text/html')
-            res.end(result)
-          })
+          if (req.headers.accept.startsWith('text/html')) {
+            const filename = path.join(bundler.outputPath, 'index.html')
+            bundler.outputFileSystem.readFile(filename, (err, result) => {
+              if (err) {
+                next(err)
+                return
+              }
+              res.setHeader('Content-Type', 'text/html')
+              res.end(result)
+            })
+          }
+          next()
         },
       ],
     },

+ 15 - 14
webpack.config.js

@@ -1,10 +1,11 @@
-const path = require('path');
-const webpack = require('webpack');
-const HtmlWebpackPlugin = require('html-webpack-plugin');
-const ExtractTextPlugin = require('extract-text-webpack-plugin');
+const path = require('path')
+const webpack = require('webpack')
+const HtmlWebpackPlugin = require('html-webpack-plugin')
+const ExtractTextPlugin = require('extract-text-webpack-plugin')
 
-const DEBUG = !(process.argv.slice(2) == '--release');
-const VERBOSE = process.argv.slice(2) == '--verbose';
+const args = process.argv.slice(2)
+const DEBUG = !(args[0] === '--release')
+const VERBOSE = args[0] === '--verbose'
 
 /**
  * Webpack configuration (core/main.js => build/bundle.js)
@@ -35,7 +36,7 @@ const config = {
       'react-router-redux',
       'redux',
       'redux-thunk',
-    ]
+    ],
   },
 
   // Options affecting the output of the compilation
@@ -79,7 +80,7 @@ const config = {
     new webpack.DefinePlugin({
       'process.env.NODE_ENV': DEBUG ? '"development"' : '"production"',
       __DEV__: DEBUG,
-      __BASENAME__: JSON.stringify(process.env.BASENAME || '')
+      __BASENAME__: JSON.stringify(process.env.BASENAME || ''),
     }),
     new ExtractTextPlugin(
       'assets/styles.css',
@@ -156,17 +157,17 @@ const config = {
       store: path.resolve(__dirname, './src/store/'),
     },
   },
-};
+}
 
 // Optimize the bundle in release (production) mode
 if (!DEBUG) {
-  config.plugins.push(new webpack.optimize.DedupePlugin());
+  config.plugins.push(new webpack.optimize.DedupePlugin())
   config.plugins.push(new webpack.optimize.UglifyJsPlugin({
     compress: { warnings: VERBOSE, screw_ie8: false },
     mangle: { screw_ie8: false },
     output: { screw_ie8: false },
-  }));
-  config.plugins.push(new webpack.optimize.AggressiveMergingPlugin());
+  }))
+  config.plugins.push(new webpack.optimize.AggressiveMergingPlugin())
   config.module.loaders
     .find(x => x.loader === 'babel-loader').query.plugins
     .unshift(
@@ -176,7 +177,7 @@ if (!DEBUG) {
     'transform-es3-modules-literals',
     'transform-es3-member-expression-literals',
     'transform-es3-property-literals'
-    );
+    )
 }
 
-module.exports = config;
+module.exports = config