Repository URL to install this package:
|
Version:
3.6.0-rc.2-c44c3ce3093350 ▾
|
const { DefinePlugin, HotModuleReplacementPlugin } = require('webpack');
const { createRouter, getSchema } = require('./mockHelper');
/**
* This is the webpack configuration used when running the frontend in development mode.
* @param {WebpackAppParameters} parameters See {@link ../webpack.js}
*/
module.exports = async parameters => {
const { publicPath, mocks } = parameters;
const schema = mocks.swaggerJson ? await getSchema(mocks.swaggerJson) : null;
return {
mode: 'development',
output: {
filename: '[name].bundle.js',
chunkFilename: '[name].bundle.js',
publicPath: `/${publicPath}`,
},
/**
* https://webpack.js.org/configuration/dev-server/
*/
devServer: {
open: true,
openPage: publicPath,
overlay: true,
historyApiFallback: true,
/**
* Expose the mock endpoints
*/
before: function injectMock(app) {
if (schema !== null) {
app.use(schema.basePath, createRouter(schema));
}
},
},
plugins: [
/**
* https://webpack.js.org/plugins/define-plugin/
*/
new DefinePlugin({
'process.env.NODE_ENV': JSON.stringify('development'),
'process.env.ASSETS_PATH': JSON.stringify(publicPath),
'process.env.BUILD_TARGET': JSON.stringify(''),
}),
/**
* https://webpack.js.org/plugins/hot-module-replacement-plugin
*/
new HotModuleReplacementPlugin(),
],
};
};