mariusbalcytis / webpack-bundle

Bundle to Integrate Webpack into Symfony
MIT License
122 stars 36 forks source link

Fix space encoding for entry files #84

Closed antonyoneill closed 6 years ago

antonyoneill commented 6 years ago

Hey there,

I found an issue when building our assets in a Jenkins job that has a space in the job name. My project contains a less file which is marked as an included entry file, the AssetResolver wraps the with the extract-file-loader but uses the wrong url encoding.

So the working directory of the maba:webpack:compile is /path/to/jenkins/My Job/workspace. I have a bundle MyBundle and a twig file that contains a webpack_asset('@MyBundle/some.less') call.

The resulting app/cache/local/webpack.config.js contains:

module.exports = require('\/path\/to\/jenkins\/My Job\/workspace\/app\/config\/webpack.config.js')({
    'entry': {
        'some-909503fdcbe6afbde10a0515e94225c45d6f03ea': 'extract-file-loader?q=%2Fpath%2Fto%2Fjenkins%2FMy+Job%2Fworkspace%2Fsrc%2FMyBundle%2F/Resources/some.less!',
    },
    'alias': {
        '@MyBundle': '\/path\/to\/jenkins\/My Job\/workspace\/src\/MyBundle',
    },
});

Notice that the space has been replaced with a + :(

Running that configuration file then causes the following error in webpack:

ERROR in ./node_modules/extract-file-loader?q=%2Fpath%2Fto%2Fjenkins%2FMy+Job%2Fworkspace%2Fsrc%2FMyBundle%2F/Resources/some.less
    Module not found: Error: Can't resolve '/path/to/jenkins/My+Job/workspace/src/MyBundle/Resources/some.less' in '/path/to/jenkins/My Job/workspace'  
    @ ./node_modules/extract-file-loader?q=%2Fpath%2Fto%2Fjenkins%2FMy+Job%2Fworkspace%2Fsrc%2FMyBundle%2F/Resources/some.less 1:17-143

I've added a couple of tests to verify the intended behaviour.