Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

one-loader and gatsby #54

Open
Zauberfisch opened this issue Sep 24, 2020 · 3 comments
Open

one-loader and gatsby #54

Zauberfisch opened this issue Sep 24, 2020 · 3 comments

Comments

@Zauberfisch
Copy link

Gatsby (and probably also next.js) abstract the webpack configuration away, and therefore make normal webpack configuration as documented in the one-loader readme.

Gatsby provides hooks to append the webpack config, but in their documentation says, you should avoid editing the webpack config and always check for an existing gatsby module first.

I've got it working with the config below, but it might be worth creating a one-loader gatsby plugin.

// gatsby-node.js

module.exports = {
	onCreateWebpackConfig: ({stage, rules, loaders, plugins, actions}) => {
		actions.setWebpackConfig({
			module: {
				rules: [
					{
						test: /\.one$/,
						use: [
							{
								loader: 'one-loader',
								options: {
									map: {
										'text/css': rules.css().use,
										'text/scss': [...rules.css().use, 'sass-loader'],
										'javascript': rules.js().use,
									}
								}
							},
						],
					},
					{
						test: /\.scss$/,
						use: [...rules.css().use, 'sass-loader'],
					},
				],
			},
		})
	},
	resolvableExtensions: () => {
		return [`.one`];
	}
}

So, should we (and is someone willing to), create a gatsby plugin?
Or should we create some documentation here to show people how to get it working manually?

@Zauberfisch
Copy link
Author

oh, and for some reason, I had to manually create a postcss.config.js, because it somehow didn't pickup the defaults that gatsby promisses to have.

@MunGell
Copy link
Collaborator

MunGell commented Sep 26, 2020

Hi @Zauberfisch

Thanks for this valuable information, I personally would say - lets start with the simplest option for the moment, then work on the rest if there is demand for that. In this particular case, if documenting such use case is easier than creating a plugin - lets have documentation done first.

Thanks again for your proactive approach to the project!

@Zauberfisch
Copy link
Author

ok, I guess I'll create an example project in the examples directory and add a 1-liner to the readme to point people there?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants