2021-06-10 06:01:49 -04:00
|
|
|
const webpack = require('webpack')
|
2022-04-06 05:59:13 -04:00
|
|
|
const { merge } = require('webpack-merge')
|
2019-11-28 05:20:22 -05:00
|
|
|
const MiniCssExtractPlugin = require('mini-css-extract-plugin')
|
2018-01-12 06:41:02 -05:00
|
|
|
|
|
|
|
const base = require('./webpack.config')
|
|
|
|
|
|
|
|
module.exports = merge(base, {
|
2019-08-06 08:20:02 -04:00
|
|
|
mode: 'development',
|
|
|
|
|
2021-01-06 04:31:57 -05:00
|
|
|
// Enable accurate source maps for dev
|
2021-03-25 10:02:21 -04:00
|
|
|
devtool: 'source-map',
|
2019-08-06 08:20:02 -04:00
|
|
|
|
2022-04-06 13:33:39 -04:00
|
|
|
// Load entrypoints without contenthash in filename
|
|
|
|
output: {
|
|
|
|
filename: 'js/[name].js',
|
|
|
|
},
|
|
|
|
|
|
|
|
// Load assets without contenthash in filename
|
|
|
|
module: {
|
|
|
|
rules: [
|
|
|
|
{
|
|
|
|
test: /\.(woff|woff2)$/,
|
|
|
|
type: 'asset/resource',
|
|
|
|
generator: {
|
|
|
|
filename: 'fonts/[name][ext]',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
test: /\.(svg|gif|png|jpg|pdf)$/,
|
|
|
|
type: 'asset/resource',
|
|
|
|
generator: {
|
|
|
|
filename: 'images/[name][ext]',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
|
|
|
|
2019-11-28 05:20:22 -05:00
|
|
|
plugins: [
|
|
|
|
// Extract CSS to a separate file (rather than inlining to a <style> tag)
|
|
|
|
new MiniCssExtractPlugin({
|
|
|
|
// Output to public/stylesheets directory
|
2021-04-27 03:52:58 -04:00
|
|
|
filename: 'stylesheets/[name].css',
|
|
|
|
}),
|
2021-06-10 06:01:49 -04:00
|
|
|
|
|
|
|
// Disable React DevTools if DISABLE_REACT_DEVTOOLS is set to "true"
|
2021-06-11 06:17:28 -04:00
|
|
|
process.env.DISABLE_REACT_DEVTOOLS === 'true' &&
|
|
|
|
new webpack.DefinePlugin({
|
|
|
|
__REACT_DEVTOOLS_GLOBAL_HOOK__: '({ isDisabled: true })',
|
|
|
|
}),
|
|
|
|
].filter(Boolean),
|
2019-11-28 05:20:22 -05:00
|
|
|
|
2019-08-06 08:20:02 -04:00
|
|
|
devServer: {
|
2021-02-22 10:01:42 -05:00
|
|
|
// Expose dev server at www.dev-overleaf.com
|
2019-08-06 08:20:02 -04:00
|
|
|
host: '0.0.0.0',
|
|
|
|
port: 3808,
|
2022-04-06 05:59:13 -04:00
|
|
|
client: {
|
|
|
|
webSocketURL: 'auto://0.0.0.0:0/ws',
|
|
|
|
},
|
|
|
|
allowedHosts: '.dev-overleaf.com',
|
|
|
|
setupMiddlewares(middlewares, devServer) {
|
|
|
|
devServer.app.get('/status', (req, res) => res.send('webpack is up'))
|
|
|
|
return middlewares
|
2021-04-27 03:52:58 -04:00
|
|
|
},
|
|
|
|
},
|
2022-04-06 05:59:13 -04:00
|
|
|
|
|
|
|
// Customise output to the (node) console
|
|
|
|
stats: {
|
|
|
|
colors: true, // Enable some coloured highlighting
|
|
|
|
// Hide some overly verbose output
|
|
|
|
performance: false, // Disable as code is uncompressed in dev mode
|
|
|
|
hash: false,
|
|
|
|
version: false,
|
|
|
|
chunks: false,
|
|
|
|
modules: false,
|
|
|
|
// Hide copied assets from output
|
|
|
|
excludeAssets: [/^js\/ace/, /^js\/libs/, /^js\/cmaps/],
|
|
|
|
},
|
2018-01-12 06:41:02 -05:00
|
|
|
})
|