Skip to content

Commit

Permalink
Upgrade webpack to v5 and associated loaders (#1344)
Browse files Browse the repository at this point in the history
  • Loading branch information
fryjordan committed Mar 14, 2022
1 parent f9da884 commit a56a90b
Show file tree
Hide file tree
Showing 6 changed files with 1,549 additions and 3,508 deletions.
56 changes: 34 additions & 22 deletions devserver.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,43 +83,55 @@ const runWebpackServer = function () {
});

const options = {
contentBase: path.join(__dirname, '/dist/debug/'),
host: 'localhost',
static: {
directory: path.join(__dirname, '/dist/debug/')
},
host: '0.0.0.0',
port: process.env.FAUXTON_PORT || 8000,
overlay: true,
client: {
overlay: true,
},
hot: false,
historyApiFallback: false,
disableHostCheck: true,
stats: {
colors: true,
allowedHosts: "auto",
devMiddleware: {
stats: {
colors: true,
},
},
headers: getCspHeaders(),
before: (app) => {
app.all('*', (req, res, next) => {
const accept = req.headers.accept ? req.headers.accept.split(',') : '';

if (/application\/json/.test(accept[0]) || /multipart\/form-data/.test(accept[0])) {
proxy.web(req, res);
return;
setupMiddlewares: (middlewares, devServer) => {
if (!devServer) {
throw new Error('webpack-dev-server is not defined');
}

middlewares.unshift(
{
name: "proxy-to-couchdb",
middleware: ('*', (req, res, next) => {
const accept = req.headers.accept ? req.headers.accept.split(',') : '';
if (/application\/json/.test(accept[0]) || /multipart\/form-data/.test(accept[0])) {
proxy.web(req, res);
return;
}

next();
}),
}
);

next();
});
}
return middlewares;
},
};

const compiler = webpack(config);
const server = new WebpackDev(compiler, options);
const server = new WebpackDev(options, compiler);

server.listen(options.port, '0.0.0.0', function (err) {
if (err) {
console.error(err);
return;
}
server.startCallback(() => {
console.info('listening on', options.host, options.port);
console.info('Starting first compile. This will take about 10 seconds...');
});
};


devSetup(runWebpackServer);
Loading

0 comments on commit a56a90b

Please sign in to comment.