Skip to content

Conversation

@lukeed
Copy link
Member

@lukeed lukeed commented Jun 28, 2017

If the user defines a .babelrc file in their root directory, we will read it & overwrite our settings with what they've specified. This is a hard/forced reset that they may choose to use.

Alternatively, a user may only want to modify the Babel configuration we've provided. Thanks to #56, they can do this now.

// preact.config.js

export default (config, env, helpers) => {
	let { rule } = helpers.getLoadersByName(config, 'babel-loader');
	rule.options.plugins.push('my-chosen-plugin');
};

Fixes #152 & others that were bound to open 😆

@lukeed
Copy link
Member Author

lukeed commented Jun 28, 2017

Oh. This is because we're picking up our own .babelrc, which compiles to Node > 4 & overwrites all our shipped config (purposefully).

@rkostrzewski
Copy link
Collaborator

IMHO preact build - should use custom .babelrc. can be ignored for now

@rkostrzewski
Copy link
Collaborator

rkostrzewski commented Jun 28, 2017

@lukeed actually it's because it's picking .babelrc in test dir which is using custom plugins array without jsx transform plugin

@lukeed
Copy link
Member Author

lukeed commented Jun 28, 2017

Right, the repo's .babelrc is being parsed & overwriting our babel config.

It's doing what it's supposed to, we just have to ignore the root .babelrc & it'll be fine 😄

@developit
Copy link
Member

We could move our babel config into the package.json

@thangngoc89
Copy link
Collaborator

My 2 cents:

Why don't we make a babel presets under preact-cli/babel for default babel config, so users can quickly pull them in. next.js does this

@lukeed
Copy link
Member Author

lukeed commented Jun 28, 2017

@thangngoc89 I was going to suggest this too. Little more difficult since we have some conditional stuff, but should still be doable.

Tests failed because sourcemaps grew as a result of embedded options. @rkostrzewski is on it 🙌

@hassanbazzi
Copy link
Member

Woooooooooo

Copy link
Collaborator

@rkostrzewski rkostrzewski left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@lukeed you're a star 🥇

@lukeed
Copy link
Member Author

lukeed commented Jun 28, 2017

@rkostrzewski no, you 🌟 Thanks for editing the how-to above 🙌

@hassanbazzi hassanbazzi merged commit bf86082 into master Jun 28, 2017
@hassanbazzi hassanbazzi deleted the fix-babelrc branch June 28, 2017 21:37
@rkostrzewski rkostrzewski added this to the 1.3.0 milestone Jul 5, 2017
@ekanna
Copy link

ekanna commented Jul 18, 2017

// preact.config.js

export default (config, env, helpers) => {
	let { rule } = helpers.getLoadersByName(config, 'babel-loader');
	rule.options.plugins.push('my-chosen-plugin');
};

helpers.getLoadersByName(config, 'babel-loader') returns array.
so change code to below in docs:

// preact.config.js

export default (config, env, helpers) => {
	let { rule } = helpers.getLoadersByName(config, 'babel-loader')[0];
	rule.options.plugins.push('my-chosen-plugin');
};

Also change in examples at
https://github.com/developit/preact-cli/wiki/Config-Recipes#customising-babel-options-using-loader-helpers

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

Successfully merging this pull request may close these issues.

7 participants