Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/457.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript Web包sass将后台url更改为base64_Javascript_Angular_Webpack_Sass - Fatal编程技术网

Javascript Web包sass将后台url更改为base64

Javascript Web包sass将后台url更改为base64,javascript,angular,webpack,sass,Javascript,Angular,Webpack,Sass,我有这个Angular应用程序,我的所有组件都嵌入了sass样式,我使用.NET Core Angular默认样板和sass loader作为我的sass编译器 知道如何将背景url更改为base 64吗 你有什么建议使用什么装载机吗 例如: body.login-page:not(.dashboard-pages) { background-image: url(/images/atc-crowd.png) <- This one to base64; backgro

我有这个Angular应用程序,我的所有组件都嵌入了sass样式,我使用.NET Core Angular默认样板和sass loader作为我的sass编译器

  • 知道如何将背景url更改为base 64吗
  • 你有什么建议使用什么装载机吗
例如:

body.login-page:not(.dashboard-pages) {
    background-image: url(/images/atc-crowd.png) <- This one to base64;
    background-position: center;
    background-repeat: no-repeat;
    background-attachment: fixed;
    background-size: cover;
    width: 650px;
    margin: 7% auto;

}
你可以用。这应该是你想要的。 您可以用此替换图像规则

{
    test: /\.(jpe?g|png|ttf|eot|svg|woff(2)?)(\?[a-z0-9=&.]+)?$/,
    use: 'base64-inline-loader?limit=1000&name=[name].[ext]'
}

但是您当前的
url加载程序也应该将图像转换为base64。您已经配置了一个限制,在此限制之后,将使用正常的
文件加载程序。你可以试试看它是否有用。

尝试过这个,但不起作用,因为sass直接嵌入到组件中,不会生成css文件。但是你的sass会从webpack被编译成css,对吗?如果这样做有效,图像加载也应该有效。我刚刚注意到你使用的是一个绝对路径,它必须是相对的。试着改变这一点。
{
    test: /\.(jpe?g|png|ttf|eot|svg|woff(2)?)(\?[a-z0-9=&.]+)?$/,
    use: 'base64-inline-loader?limit=1000&name=[name].[ext]'
}