Skip to content

Allow pre-pending loaders to the built in ones #852

@claytron5000

Description

@claytron5000

I wanted to improve build times for ts files by using the thread-loader. In order to do this I need to prepend the thread-loader ahead of the encore-build loaders. I did an ugly hack to get it to work, but it would be nice feature to allow more granular control.

This is my hack-around.

const pack = Encore.getWebpackConfig();

pack.module.rules.forEach(rule => {
	
	if (rule.test.test('.ts')) {
		
		// this could be configured above, but this way all the threading config is in one place.
		rule.use.forEach(loader => {
			if (loader.loader === 'ts-loader') {
				loader.options.happyPackMode = true;
			}
		})
		rule.use.unshift({loader: 'thread-loader', options: {
			workers: 2
		}})
	}
})

Unrelated issue where the same request is made: #249

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions