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

Add proper typescript webpack setup in readme #1778

Closed
GeeWee opened this issue Aug 31, 2017 · 4 comments
Closed

Add proper typescript webpack setup in readme #1778

GeeWee opened this issue Aug 31, 2017 · 4 comments

Comments

@GeeWee
Copy link

GeeWee commented Aug 31, 2017

The current webpack typescript setup in the readme: is off. First off, it doesn't import path, and thus doesn't even run.

Secondly, it fails miserably, if the files in the '/stories/' folder is typescript, as it'sn ot listed in the include param.
A webpack config that works looks something like this:

// load the default config generator.
const genDefaultConfig = require('@storybook/react/dist/server/config/defaults/webpack.config.js');
const path = require('path');

module.exports = (baseConfig, env) => {
	const config = genDefaultConfig(baseConfig, env);
	
	// Extend it as you need.
	
	// For example, add typescript loader:
	config.module.rules.push({
		test: /\.(ts|tsx)$/,
		include: [
			path.resolve(__dirname, '../src'),
			path.resolve(__dirname, '../stories'),
			],
		loader: require.resolve('awesome-typescript-loader'),
	});
	config.resolve.extensions.push('.ts', '.tsx');
	
	return config;
};
@danielduan
Copy link
Member

@matt-erhart
Copy link

I hadn't even considered the docs were wrong until spending a bunch of time on this. Let's get this fixed asap. I can pr later if need be.

@GeeWee
Copy link
Author

GeeWee commented Sep 27, 2017

It'd be awesome if you did this - I've had it on my to do list for a while but I've been crazy busy

@danielduan
Copy link
Member

closing this in favor of #3270

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

No branches or pull requests

3 participants