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

Better defaults for Typescript example #593

Merged
merged 2 commits into from
Apr 30, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 23 additions & 23 deletions examples/with-typescript/razzle.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ module.exports = {
'.ts',
'.tsx',
]);


config.devtool = 'cheap-module-source-map';
Copy link
Owner

Choose a reason for hiding this comment

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

Think this will break HMR if you remove.

Copy link
Author

Choose a reason for hiding this comment

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

Copy link
Owner

Choose a reason for hiding this comment

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

Good looks.


// Locate eslint-loader and remove it (we're using tslint instead)
config.module.rules = config.module.rules.filter(
Expand All @@ -21,6 +21,17 @@ module.exports = {
'useEslintrc' in rule.use[0].options
)
);
// Add tslint-loader
config.module.rules.push({
include,
enforce: 'pre',
test: /\.tsx?$/,
loader: 'tslint-loader',
options: {
emitErrors: true,
configFile: './tslint.json',
},
});

// Safely locate Babel-Loader in Razzle's webpack internals
const babelLoader = config.module.rules.findIndex(
Expand All @@ -40,31 +51,20 @@ module.exports = {
transpileOnly: true,
},
};

const tslintLoader = {
include,
enforce: 'pre',
test: /\.tsx?$/,
loader: 'tslint-loader',
options: {
emitErrors: true,
configFile: './tslint.json',
},
};

config.module.rules.push(tslintLoader);

// Fully replace babel-loader with ts-loader
config.module.rules[babelLoader] = tsLoader;

// If you want to use Babel & Typescript together (e.g. if you
// are migrating incrementally and still need some Babel transforms)
// Add loader
config.module.rules.push(tsLoader)

// Additional options found at https://github.com/TypeStrong/ts-loader#faster-builds
// Add async typechecking errors
// config.plugins.push(new require('fork-ts-checker-webpack-plugin')())

// If you want to replace Babel with typescript to fully speed up build
// then do the following:
//
// - COMMENT out line 59
// - UNCOMMENT line 68
// - COMMENT out line 55
// - UNCOMMENT line 67
//
// config.module.rules.push(tsLoader)
// config.module.rules[babelLoader] = tsLoader;

return config;
},
Expand Down