Skip to content

Conversation

Lyrkan
Copy link
Collaborator

@Lyrkan Lyrkan commented Oct 13, 2017

Due to the following lines a new ts-loader rule is currently being added everytime the Webpack config is generated (for instance by calling Encore.getWebpackConfig()):

this.webpackConfig.addLoader({
test: /\.tsx?$/,
exclude: /node_modules/,
use: tsLoaderUtil.getLoaders(this.webpackConfig)
});

Example:

// webpack.config.js
const Encore = require('@symfony/webpack-encore');

Encore
    .setOutputPath('build')
    .setPublicPath('/')
    .addEntry('src/index.ts')
    .enableTypeScriptLoader()
;

console.log(Encore.getWebpackConfig().module.rules.length); // => 5
console.log(Encore.getWebpackConfig().module.rules.length); // => 6
console.log(Encore.getWebpackConfig().module.rules.length); // => 7

@Lyrkan Lyrkan added the Bug Bug Fix label Oct 13, 2017
@weaverryan
Copy link
Member

Wow, nice catch. Thanks @Lyrkan!

@weaverryan weaverryan merged commit a2515b4 into symfony:master Oct 14, 2017
weaverryan added a commit that referenced this pull request Oct 14, 2017
…called (Lyrkan)

This PR was merged into the master branch.

Discussion
----------

Fix new ts-loader rule being added when getWebpackConfig is called

Due to the following lines a new ts-loader rule is currently being added everytime the Webpack config is generated (for instance by calling `Encore.getWebpackConfig()`):

https://github.com/symfony/webpack-encore/blob/c6057af7521594d9d76cfd072b1f2421591e4a3f/lib/config-generator.js#L196-L200

__Example:__

```js
// webpack.config.js
const Encore = require('@symfony/webpack-encore');

Encore
    .setOutputPath('build')
    .setPublicPath('/')
    .addEntry('src/index.ts')
    .enableTypeScriptLoader()
;

console.log(Encore.getWebpackConfig().module.rules.length); // => 5
console.log(Encore.getWebpackConfig().module.rules.length); // => 6
console.log(Encore.getWebpackConfig().module.rules.length); // => 7
```

Commits
-------

a2515b4 Fix ts-loader being added everytime getWebpackConfig is called
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Bug Bug Fix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants