{"size": 1629, "ext": "js", "max_stars_repo_path": "build-utils/webpack.dev.js", "max_stars_repo_name": "barslev/ccms-components", "max_stars_repo_stars_event_min_datetime": "2016-05-25T07:44:17.000Z", "max_stars_repo_stars_event_max_datetime": "2019-08-12T05:45:25.000Z", "max_issues_repo_path": "build-utils/webpack.dev.js", "max_issues_repo_name": "barslev/ccms-components", "max_issues_repo_issues_event_min_datetime": "2016-05-25T04:39:51.000Z", "max_issues_repo_issues_event_max_datetime": "2021-08-10T10:51:45.000Z", "max_forks_repo_path": "build-utils/webpack.dev.js", "max_forks_repo_name": "barslev/ccms-components", "max_forks_repo_forks_event_min_datetime": "2016-05-25T08:07:40.000Z", "max_forks_repo_forks_event_max_datetime": "2020-03-05T12:06:25.000Z"}
{"max_stars_count": 65, "max_issues_count": 353, "max_forks_count": 71, "avg_line_length": 21.1558441558, "max_line_length": 66, "alphanum_fraction": 0.5807243708}
const path = require('path');
const webpack = require('webpack');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const bodyParser = require('body-parser');

const { gridData, menuData, shopsData } = require('../mock/mock');
const { version } = require('../package.json');
const publicPath = '/';


module.exports = () => ({
	mode: 'development',
	devtool: 'source-map',
	entry: {
		components: './src/index.js'
	},
	output: {
		path: path.join(__dirname, 'build'),
		filename: '[name].js',
		publicPath
	},
	devServer: {
		disableHostCheck: true,
		proxy: {
			'/api': {
				target: 'http://localhost:8080',
				pathRewrite: { '^/api': '' },
				logLevel: 'debug'
			}
		},
		before(app) {
			app.use(bodyParser.json());
			app.use(bodyParser.urlencoded({ extended: false }));

			app.get('/pages/1', (req, res) => {
				res.json(gridData);
			});

			app.get('/menus', (req, res) => {
				res.json(menuData);
			});

			app.get('/shops', (req, res) => {
				res.json(shopsData);
			});
		}
	},
	plugins: [
		new webpack.DefinePlugin({
			'process.env': {
				VERSION: JSON.stringify(version)
			}
		}),
		new webpack.HotModuleReplacementPlugin(),
		new HtmlWebpackPlugin({
			filename: 'index.html',
			template: 'demos/index.html',
			favicon: 'demos/favicon.ico'
		})
	],
	module: {
		rules: [
			{
				test: /\.(sc|c)ss$/,
				use: [
					{ loader: 'style-loader' },
					{ loader: 'css-loader', options: { sourceMap: true } },
					{ loader: 'postcss-loader' },
					{ loader: 'resolve-url-loader' },
					{ loader: 'sass-loader', options: { sourceMap: true } }
				],
				exclude: /node_modules/
			}
		]
	}
});
