Giter Club home page Giter Club logo

Comments (3)

harishanchu avatar harishanchu commented on May 31, 2024

If you take a look at api docs it's possible to provide additional scripts to pretty page handler. Would that be good enough?

from ouch.

lighth7015 avatar lighth7015 commented on May 31, 2024

Yeah, I'll just have to find the time to create an error handler for webpack.

from ouch.

lighth7015 avatar lighth7015 commented on May 31, 2024

=== Update ===
So I've been playing around with Ouch, and this is the closest thing I can figure to something that works, but it won't for some reason-

var Ouch = require('ouch')
var utils = require('./utils')
var webpack = require('webpack')
var config = require('../config')
var merge = require('webpack-merge')
var baseWebpackConfig = require('./webpack.base.conf')
var HtmlWebpackPlugin = require('html-webpack-plugin')

const { HotModuleReplacementPlugin, DefinePlugin, NoEmitOnErrorsPlugin } = webpack;

// add hot-reload related code to entry chunks
Object.keys(baseWebpackConfig.entry).forEach((name) => (
	baseWebpackConfig.entry[name] = ['./build/dev-client'].concat(baseWebpackConfig.entry[name]) ))

module.exports = merge(baseWebpackConfig, {
	module: {
		rules: utils.styleLoaders({ sourceMap: config.dev.cssSourceMap })
	},
	
	// cheap-module-eval-source-map is faster for development
	devtool: '#cheap-module-eval-source-map',
	devServer: {
		host: '0.0.0.0',
		port: 8800,
		
		before(app) {
			const ouch = new Ouch();
			const { handlers: { PrettyPageHandler }} = Ouch;
			
			const logError = () => 
				console.log('Error handled');
			
			app.use((err, req, res, next) => (
				ouch.pushHandler(new PrettyPageHandler())
					.handleException(err, req, res, logError)));
			
			console.log(instance);
			console.log(app);
		},
	},
	
	plugins: [
		new DefinePlugin({
			'process.env': config.dev.env
		}),
		
		// https://github.com/glenjamin/webpack-hot-middleware#installation--usage
		new HotModuleReplacementPlugin(),
		new NoEmitOnErrorsPlugin(),
		
		// https://github.com/ampedandwired/html-webpack-plugin
		new HtmlWebpackPlugin({
			filename: 'index.html',
			template: 'index.html',
			inject: true
		})
	]
})

from ouch.

Related Issues (8)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.