Fix webpack config url in css

This commit is contained in:
Maxime GRIS
2017-04-21 20:18:46 +02:00
parent 0a93ebe96a
commit cea4be57ba

View File

@@ -136,7 +136,7 @@ module.exports = {
],
"fallback": "style-loader",
"publicPath": ""
})
})
},
{
"include": [
@@ -151,7 +151,7 @@ module.exports = {
],
"fallback": "style-loader",
"publicPath": ""
})
})
},
{
"include": [
@@ -166,7 +166,7 @@ module.exports = {
],
"fallback": "style-loader",
"publicPath": ""
})
})
},
{
"include": [
@@ -181,7 +181,7 @@ module.exports = {
],
"fallback": "style-loader",
"publicPath": ""
})
})
},
{
"test": /\.ts$/,
@@ -252,24 +252,24 @@ module.exports = {
"options": {
"postcss": [
autoprefixer(),
postcssUrl({"url": (URL) => {
postcssUrl({"url": (obj) => {
// Only convert root relative URLs, which CSS-Loader won't process into require().
if (!URL.startsWith('/') || URL.startsWith('//')) {
return URL;
if (!obj.url.startsWith('/') || obj.url.startsWith('//')) {
return obj.url;
}
if (deployUrl.match(/:\/\//)) {
// If deployUrl contains a scheme, ignore baseHref use deployUrl as is.
return `${deployUrl.replace(/\/$/, '')}${URL}`;
return `${deployUrl.replace(/\/$/, '')}${obj.url}`;
}
else if (baseHref.match(/:\/\//)) {
// If baseHref contains a scheme, include it as is.
return baseHref.replace(/\/$/, '') +
`/${deployUrl}/${URL}`.replace(/\/\/+/g, '/');
`/${deployUrl}/${obj.url}`.replace(/\/\/+/g, '/');
}
else {
// Join together base-href, deploy-url and the original URL.
// Also dedupe multiple slashes into single ones.
return `/${baseHref}/${deployUrl}/${URL}`.replace(/\/\/+/g, '/');
return `/${baseHref}/${deployUrl}/${obj.url}`.replace(/\/\/+/g, '/');
}
}})
],