Skip to content

Commit

Permalink
improve config options
Browse files Browse the repository at this point in the history
  • Loading branch information
jpavon committed Jun 22, 2018
1 parent 9c91ce8 commit 97801ae
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 113 deletions.
67 changes: 9 additions & 58 deletions config/webpack.config.dev.js
Original file line number Diff line number Diff line change
Expand Up @@ -177,41 +177,14 @@ module.exports = {
// https://twitter.com/wSokra/status/969633336732905474
// https://medium.com/webpack/webpack-4-code-splitting-chunk-graph-and-the-splitchunks-optimization-be739a861366
splitChunks: {
chunks: 'all',
name: 'vendors',
},
// Keep the runtime chunk seperated to enable long term caching
// https://twitter.com/wSokra/status/969679223278505985
runtimeChunk: true,
chunks: 'all'
}
},
module: {
strictExportPresence: true,
rules: [
// Disable require.ensure as it's not a standard language feature.
{ parser: { requireEnsure: false } },

{
test: /\.(js|jsx|mjs)$/,
enforce: 'pre',
use: [
// {
// options: {
// formatter: eslintFormatter,
// eslintPath: require.resolve('eslint'),
// baseConfig: {
// extends: [require.resolve('eslint-config-react-app')],
// },
// // @remove-on-eject-begin
// ignore: false,
// useEslintrc: false,
// // @remove-on-eject-end
// },
// loader: require.resolve('eslint-loader'),
// },
],
include: paths.srcPaths,
exclude: [/[/\\\\]node_modules[/\\\\]/],
},
{
// "oneOf" will traverse all following loaders until one will
// match the requirements. When no loader matches it will fall
Expand All @@ -231,7 +204,7 @@ module.exports = {
{
test: /\.(js|jsx|mjs)$/,
include: paths.srcPaths,
exclude: [/[/\\\\]node_modules[/\\\\]/],
exclude: /[\\/]node_modules[\\/]/,
use: [
// This loader parallelizes code compilation, it is optional but
// improves compile time on larger projects
Expand Down Expand Up @@ -279,47 +252,27 @@ module.exports = {
},
],
},
// Compile .tsx
// {
// test: /\.tsx?$/,
// use: [
// {
// loader: require.resolve('thread-loader'),
// options: {
// // there should be 1 cpu for the fork-ts-checker-webpack-plugin
// workers: require('os').cpus().length - 1,
// },
// },
// {
// loader: require.resolve('ts-loader'),
// options: {
// transpileOnly: true,
// happyPackMode: true
// }
// }
// ]
// },
// Compile .ts and .tsx
{
test: /\.tsx?$/,
exclude: [/[/\\\\]node_modules[/\\\\]/],
include: paths.srcPaths,
exclude: /[\\/]node_modules[\\/]/,
use: [
{
loader: require.resolve('awesome-typescript-loader'),
options: {
silent: true,
useCache: true,
transpileOnly: true,
reportFiles: [
paths.appSrc + '/**/*.{ts,tsx}'
],
forceIsolatedModules: true,
useBabel: true,
babelOptions: {
babelrc: false,
compact: true,
compact: false,
presets: [
require.resolve('@babel/preset-react'),
],
highlightCode: true,
},
babelCore: require.resolve('@babel/core'),
},
Expand Down Expand Up @@ -376,9 +329,7 @@ module.exports = {
{
test: /\.svg$/,
issuer: /\.tsx?$/,
use: [{
loader: require.resolve('@svgr/webpack')
}]
use: [require.resolve('@svgr/webpack')]
},
// "file" loader makes sure those assets get served by WebpackDevServer.
// When you `import` an asset, you get its (virtual) filename.
Expand Down
69 changes: 16 additions & 53 deletions config/webpack.config.prod.js
Original file line number Diff line number Diff line change
Expand Up @@ -158,15 +158,17 @@ module.exports = {
}),
new OptimizeCSSAssetsPlugin(),
],
// // Automatically split vendor and commons
// // https://twitter.com/wSokra/status/969633336732905474
// // https://medium.com/webpack/webpack-4-code-splitting-chunk-graph-and-the-splitchunks-optimization-be739a861366
// Use splitChunks when this issue is fixed:
// https://github.com/webpack/webpack/issues/7300

// Automatically split vendor and commons
// https://twitter.com/wSokra/status/969633336732905474
// https://medium.com/webpack/webpack-4-code-splitting-chunk-graph-and-the-splitchunks-optimization-be739a861366
// splitChunks: {
// chunks: 'all',
// name: 'vendors',
// chunks: 'all'
// },
// // Keep the runtime chunk seperated to enable long term caching
// // https://twitter.com/wSokra/status/969679223278505985
// Keep the runtime chunk seperated to enable long term caching
// https://twitter.com/wSokra/status/969679223278505985
// runtimeChunk: true,
},
resolve: {
Expand Down Expand Up @@ -226,30 +228,6 @@ module.exports = {
rules: [
// Disable require.ensure as it's not a standard language feature.
{ parser: { requireEnsure: false } },
{
test: /\.(js|jsx|mjs)$/,
enforce: 'pre',
// use: [
// {
// options: {
// formatter: eslintFormatter,
// eslintPath: require.resolve('eslint'),
// // TODO: consider separate config for production,
// // e.g. to enable no-console and no-debugger only in production.
// baseConfig: {
// extends: [require.resolve('eslint-config-react-app')],
// },
// // @remove-on-eject-begin
// ignore: false,
// useEslintrc: false,
// // @remove-on-eject-end
// },
// loader: require.resolve('eslint-loader'),
// },
// ],
include: paths.srcPaths,
exclude: [/[/\\\\]node_modules[/\\\\]/],
},
{
// "oneOf" will traverse all following loaders until one will
// match the requirements. When no loader matches it will fall
Expand All @@ -268,7 +246,7 @@ module.exports = {
{
test: /\.(js|jsx|mjs)$/,
include: paths.srcPaths,
exclude: [/[/\\\\]node_modules[/\\\\]/],
exclude: /[\\/]node_modules[\\/]/,
use: [
// This loader parallelizes code compilation, it is optional but
// improves compile time on larger projects
Expand All @@ -291,30 +269,16 @@ module.exports = {
},
],
},
// Compile .tsx
// {
// test: /\.tsx?$/,
// include: paths.srcPaths,
// exclude: [/[/\\\\]node_modules[/\\\\]/],
// use: [
// {
// loader: require.resolve('ts-loader'),
// options: {
// // enable type checker
// transpileOnly: false
// }
// }
// ]
// },
// Compile .ts and .tsx
{
test: /\.tsx?$/,
exclude: [/[/\\\\]node_modules[/\\\\]/],
include: paths.srcPaths,
exclude: /[\\/]node_modules[\\/]/,
use: [
{
loader: 'awesome-typescript-loader',
loader: require.resolve('awesome-typescript-loader'),
options: {
silent: true,
useCache: false,
transpileOnly: false,
reportFiles: [
paths.appSrc + '/**/*.{ts,tsx}'
],
Expand All @@ -326,9 +290,8 @@ module.exports = {
presets: [
require.resolve('@babel/preset-react'),
],
highlightCode: true,
},
babelCore: '@babel/core',
babelCore: require.resolve('@babel/core'),
},
},
]
Expand Down
4 changes: 2 additions & 2 deletions template/tslint.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"member-ordering": false,
"jsx-no-lambda": false,
"interface-name": false,
"no-shadowed-variable": false,
"no-any": true
}
},
"defaultSeverity": "warning"
}

0 comments on commit 97801ae

Please sign in to comment.