forcing webpackdev server to write files
parent
bc31135c2d
commit
726e81c88e
|
|
@ -12,6 +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 getClientEnvironment = require('./env');
|
||||
const paths = require('./paths');
|
||||
// Webpack uses `publicPath` to determine where the app is being served from.
|
||||
|
|
@ -253,7 +254,8 @@ module.exports = {
|
|||
new ManifestPlugin({
|
||||
fileName: 'asset-manifest.json',
|
||||
}),
|
||||
new webpack.IgnorePlugin(/^\.\/locale$/, /moment$/)
|
||||
new webpack.IgnorePlugin(/^\.\/locale$/, /moment$/),
|
||||
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.
|
||||
|
|
|
|||
|
|
@ -2786,6 +2786,12 @@
|
|||
"version": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz",
|
||||
"integrity": "sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM="
|
||||
},
|
||||
"moment": {
|
||||
"version": "2.18.1",
|
||||
"resolved": "https://registry.npmjs.org/moment/-/moment-2.18.1.tgz",
|
||||
"integrity": "sha1-w2GT3Tzhwu7SrbfIAtu8d6gbHA8=",
|
||||
"dev": true
|
||||
},
|
||||
"ms": {
|
||||
"version": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz",
|
||||
"integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g="
|
||||
|
|
@ -4769,6 +4775,12 @@
|
|||
"integrity": "sha1-+Aek8LHZ6ROuekgRLmzDrxmRtF8=",
|
||||
"dev": true
|
||||
},
|
||||
"write-file-webpack-plugin": {
|
||||
"version": "4.1.0",
|
||||
"resolved": "https://registry.npmjs.org/write-file-webpack-plugin/-/write-file-webpack-plugin-4.1.0.tgz",
|
||||
"integrity": "sha512-KkFZtNeeuSjig5sACrd0n1ybrpd4CS8P5J2TGEklS7UGGlz+iISAxJf426XwaQ2TTlTAq1LTXRBWTTEYjy5e4A==",
|
||||
"dev": true
|
||||
},
|
||||
"xdg-basedir": {
|
||||
"version": "https://registry.npmjs.org/xdg-basedir/-/xdg-basedir-2.0.0.tgz",
|
||||
"integrity": "sha1-7byQPMOF/ARSPZZqM1UEtVBNG9I=",
|
||||
|
|
|
|||
|
|
@ -59,7 +59,8 @@
|
|||
"webpack": "2.6.0",
|
||||
"webpack-dev-server": "2.4.5",
|
||||
"webpack-manifest-plugin": "^1.1.0",
|
||||
"whatwg-fetch": "2.0.3"
|
||||
"whatwg-fetch": "2.0.3",
|
||||
"write-file-webpack-plugin": "^4.1.0"
|
||||
},
|
||||
"scripts": {
|
||||
"start": "node scripts/start.js",
|
||||
|
|
|
|||
|
|
@ -112,14 +112,10 @@ if (!checkRequiredFiles([paths.appHtml, paths.appIndexJs])) {
|
|||
// process.exit(1);
|
||||
// }
|
||||
// );
|
||||
fs.emptyDirSync(paths.appBuild);
|
||||
fs.ensureSymlink(paths.appPng,path.resolve(paths.appBuild,'png'));
|
||||
// Merge with the public folder
|
||||
copyPublicFolder();
|
||||
startWebPackDevServer(()=>{
|
||||
child_process.spawn('webpack',['--watch','--config','config/webpack.config.flask.js'],{
|
||||
stdio:'inherit'
|
||||
});
|
||||
// child_process.spawn('webpack',['--watch','--config','config/webpack.config.flask.js'],{
|
||||
// stdio:'inherit'
|
||||
// });
|
||||
child_process.spawn('python',['walle-server.py'],{
|
||||
stdio:'inherit'
|
||||
});
|
||||
|
|
@ -173,7 +169,10 @@ function copyPublicFolder() {
|
|||
function startWebPackDevServer(pyServer){
|
||||
const DEFAULT_PORT = parseInt(process.env.PORT, 10) || 3000;
|
||||
const HOST = process.env.HOST || '0.0.0.0';
|
||||
|
||||
fs.emptyDirSync(paths.appBuild);
|
||||
fs.ensureSymlink(paths.appPng,path.resolve(paths.appBuild,'png'));
|
||||
// Merge with the public folder
|
||||
copyPublicFolder();
|
||||
// We attempt to use the default port but if it is busy, we offer the user to
|
||||
// run on a different port. `detect()` Promise resolves to the next free port.
|
||||
choosePort(HOST, DEFAULT_PORT)
|
||||
|
|
@ -200,14 +199,13 @@ function startWebPackDevServer(pyServer){
|
|||
if (err) {
|
||||
return console.log(err);
|
||||
}
|
||||
// if (isInteractive) {
|
||||
// clearConsole();
|
||||
// }
|
||||
if (isInteractive) {
|
||||
clearConsole();
|
||||
const urls = prepareUrls(protocol, HOST, '5000');
|
||||
pyServer();
|
||||
openBrowser(urls.localUrlForBrowser);
|
||||
}
|
||||
});
|
||||
// openBrowser(urls.localUrlForBrowser);
|
||||
})
|
||||
.catch(err => {
|
||||
if (err && err.message) {
|
||||
|
|
|
|||
|
|
@ -13,11 +13,11 @@ def walle_test():
|
|||
|
||||
# hmr streaming
|
||||
# from flask import Response,stream_with_context
|
||||
# @app.route('/sockjs-node/<path:url>',methods=['GET','POST'])
|
||||
# @app.route('/<path:url>',methods=['GET','POST'])
|
||||
# def walle_hmr(url):
|
||||
# webpack_server = 'http://localhost:3000/sockjs-node/'
|
||||
# webpack_server = 'http://localhost:3000/'
|
||||
# req = requests.get(webpack_server+url, stream = True)
|
||||
# return Response(stream_with_context(req.iter_content()))
|
||||
# return Response(stream_with_context(req.iter_content()))
|
||||
|
||||
if __name__ == '__main__':
|
||||
app.run(debug=True)
|
||||
|
|
|
|||
Loading…
Reference in New Issue