You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
filepizza/src/middleware/javascript.js

16 lines
500 B
JavaScript

const path = require('path')
;const BUNDLE_PATH = path.resolve(__dirname, '../../dist/bundle.js')
;if (process.env.NODE_ENV === 'production') {
module.exports = function (req, res) {
res.sendFile(BUNDLE_PATH)
};
} else {
const webpackMiddleware = require('webpack-dev-middleware')
;const webpack = require('webpack')
;const config = require('../../webpack.config.js')
;config.output.filename = '/app.js';
config.output.path = '/';
module.exports = webpackMiddleware(webpack(config))
}