using webpack proxying for api endpoint, serving static assets via webpack

master
Malar Kannan 2017-07-29 23:16:40 +05:30
parent a26d63881b
commit 6c92ac627c
4 changed files with 14 additions and 14 deletions

View File

@ -12,7 +12,7 @@ const InterpolateHtmlPlugin = require('react-dev-utils/InterpolateHtmlPlugin');
const SWPrecacheWebpackPlugin = require('sw-precache-webpack-plugin');
const WatchMissingNodeModulesPlugin = require('react-dev-utils/WatchMissingNodeModulesPlugin');
const ModuleScopePlugin = require('react-dev-utils/ModuleScopePlugin');
const WriteFilePlugin = require('write-file-webpack-plugin');
// const WriteFilePlugin = require('write-file-webpack-plugin');
const getClientEnvironment = require('./env');
const paths = require('./paths');
// Webpack uses `publicPath` to determine where the app is being served from.
@ -282,7 +282,7 @@ module.exports = {
stripPrefix: paths.appBuild.replace(/\\/g, '/') + '/',
}),
new webpack.IgnorePlugin(/^\.\/locale$/, /moment$/),
new WriteFilePlugin()
// new WriteFilePlugin()
],
// Some libraries import Node modules but don't use them in the browser.
// Tell Webpack to provide empty mocks for them so importing them works.

View File

@ -65,7 +65,7 @@ module.exports = function(proxy, allowedHost) {
// Reportedly, this avoids CPU overload on some systems.
// https://github.com/facebookincubator/create-react-app/issues/293
watchOptions: {
ignored: /node_modules/,
ignored: [/node_modules/,'public/png/*']
},
// Enable HTTPS if the HTTPS environment variable is set to 'true'
https: protocol === 'https',

View File

@ -157,11 +157,11 @@ function build(previousFileSizes) {
function copyPublicFolder() {
fs.emptyDirSync(paths.appBuild);
fs.ensureSymlink(paths.appPng,path.resolve(paths.appBuild,'png'));
fs.copySync(paths.appPublic, paths.appBuild, {
dereference: true,
filter: file => file !== paths.appHtml && file !== paths.appPng,
});
// fs.ensureSymlink(paths.appPng,path.resolve(paths.appBuild,'png'));
// fs.copySync(paths.appPublic, paths.appBuild, {
// dereference: true,
// filter: file => file !== paths.appHtml && file !== paths.appPng,
// });
}
// Tools like Cloud9 rely on this.

View File

@ -10,14 +10,14 @@ xmlDir = 'public/'
# from flask_cors import CORS, cross_origin
# CORS(app)
@app.route('/')
def walle_index():
return app.send_static_file('index.html')
# @app.route('/')
# def walle_index():
# return app.send_static_file('index.html')
@app.route('/api/test')
def walle_test():
return "test"
# @app.route('/api/test')
# def walle_test():
# return "test"
@app.route('/api/morph')
def walle_morph():