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

Using webpack alias false breaks build #1291

Closed
mmarton opened this issue Apr 19, 2021 · 4 comments · Fixed by #1292
Closed

Using webpack alias false breaks build #1291

mmarton opened this issue Apr 19, 2021 · 4 comments · Fixed by #1292

Comments

@mmarton
Copy link

mmarton commented Apr 19, 2021

  • Operating System: linux mint 20
  • Node Version: 15.11
  • NPM Version: 7.6 (but I use yarn: 1.22.5)
  • webpack Version: 5.33.2
  • css-loader Version: 5.2.3

Expected Behavior

If I alias something to false in webpack config to not to get resolved, the build breaks. Expected to work.
https://webpack.js.org/configuration/resolve/#resolvealias

null-loader is deprecated in webpack 5. use alias: { xyz$: false } or absolute path alias: {[path.resolve(__dirname, './path/to/module')]: false }

Actual Behavior

ERROR in ./index.scss
Module build failed (from ./node_modules/css-loader/dist/cjs.js):
TypeError: request.split is not a function
    at stringifyRequest (/home/mm/PhpstormProjects/css-loader-poc/node_modules/loader-utils/lib/stringifyRequest.js:16:28)
    at Object.urlHandler (/home/mm/PhpstormProjects/css-loader-poc/node_modules/css-loader/dist/index.js:95:60)
    at OnceExit (/home/mm/PhpstormProjects/css-loader-poc/node_modules/css-loader/dist/plugins/postcss-url-parser.js:324:30)
    at processTicksAndRejections (node:internal/process/task_queues:94:5)
    at async LazyResult.runAsync (/home/mm/PhpstormProjects/css-loader-poc/node_modules/postcss/lib/lazy-result.js:388:13)
    at async Object.loader (/home/mm/PhpstormProjects/css-loader-poc/node_modules/css-loader/dist/index.js:139:14)

Code

const path = require('path');
module.exports = {
    entry: './index.css',
    output: {
        path: path.resolve(__dirname, 'dist'),
        filename: 'build.css'
    },
    module: {
        rules: [
            {
                test: /\.css$/,
                use: {loader: 'css-loader'}
            }
        ]
    },
    resolve: {
        alias: {'/logo.png': false}
    }
}
.logo {
    background-image: url(/logo.png);
}

How Do We Reproduce?

@alexander-akait
Copy link
Member

Yep, bug, WIP on this

@alexander-akait
Copy link
Member

#1292

@mmarton
Copy link
Author

mmarton commented Apr 19, 2021

less than 3hour from issue submission to a new release? nice. where's the donate button? :)

@alexander-akait
Copy link
Member

Above (where panel with stars/forks/etc) 😄 Sponsor (https://opencollective.com/webpack)

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

Successfully merging a pull request may close this issue.

2 participants