I am using Web Essentials 2013 in a project to compile less to css on build/save. However, I am having problems with that when compiling, WE is tampering the relative paths to fonts/images etc.
For example:
.footer {
background: url('../img/footer_background.svg') no-repeat top center;
}
becomes:
.footer {
background: url('img/footer_background.svg') no-repeat top center;
}
I recall having a simillar issue before, but settings "Adjust relative paths" to false in web essentials CSS options fixed it then. It doesn't seem to do it now. I have tried both the latest stable and the latest nightly, both giving same behavior.
Any suggestions? :)
I know you mentioned 2013, but I had this same problem in 2015 and found if I set "relativeUrls": false in compilerconfig.json.defaults then the mentioned issue stops. For reference I'm using VS 2015 Pro upd2 and Web Compiler extension v1.11.315.
mlhDev's answer is close, but I actually had to change this in the compilerconfig.json file, NOT the defaults file, per the project's GitHub issue. My config looks like:
[
{
"outputFile": "StyleSheets/something.css",
"inputFile": "StyleSheets/scss/something.scss",
"options": {
"relativeUrls": false
}
}
]
I'm using Visual Studio Enterprise 2015 for reference, but should work in other versions.
I've run into this as well. It used to a problem in earlier versions of Web Essentials, but was eventually fixed. Now it seems to have cropped back up in 2013.
One way that I've seen to fix this is to escape the url path, which causes the less compiler to treat the value as a string literal, which it passes through as-is without touching it.
ex:
background-image: ~"url('../../../img/foo.png')";
will emit as:
background-image: url('../../../img/foo.png');
In case anyone still runs into this, in your bundleconfig.json add the adjustRelativePaths key to the minification options as follows:
"minify": {
"enabled": true,
"adjustRelativePaths": false
}
This key is used in the BundleHandler static class here, look at the method AdjustRelativePaths.
I use Web Essentials for LESS as well, and while I haven't seen it do this, I have a better solution for you. Rather than writing paths out in your code, especially if all you're changing is just the file name at the end, try using a variable for your paths.
Example:
#imgURL: "../img";
Then to use it, all you need is:
.footer{
background: url("#{imgURL}/footer_background.svg");
}
I am experiencing this same issue with bootstrap, which uses relative paths for fonts. I believe the issue lies with node-sass or libsass.
I have been unable to find information about relative path rewrites in either library, however. If it can be fixed, then a fix might be to drop in a new node-sass version.
Unfortunately, I can't find where WebEssentials is installed on my system to test this out.
I just realized you are having issues with the LESS compiler, not SASS. I wonder if the issue has more to do with the CSS minifier now.
I changed my "Custom output directory" to "../" which is where I want it to write. This causes the rewrite. If I leave it empty, the relative paths are left alone.
Related
Steps to reproduce
I have application bootstrapped from vue-cli with a webpack template. I'm running it on Chrome 65.0.3325.146 but it also exists on 64.X.XXX version.
I'm adding here:
package.json: https://gist.github.com/marcinlesek/a7e6076ce4befe2e810743fdbaf81480
webpack.base.conf.js: https://gist.github.com/marcinlesek/80cbf27b6ef4172248709f32c257d0cd
What is expected?
The application should works fine with Chrome Browser and I should be able to disable/change styles in Chrome Dev Tools.
What is actually happening?
When I change style via Chrome dev tools it broke all styles (after changing or disabling one property) that page looks like in pure HTML without any line of style code. Fresh dev tools setup and Chrome reinstall doesn't help. What is a bit tricky, on Firefox 58.0.2 everything works correctly.
My collegues also had this problem, so it convince me that it isn't my local bug but something bigger on Vue side. Also find some questions regarding this bug, like Page styles break when I change styles in Chrome DevTools with Webpack HMR
Thanks in advance.
Best regards,
Marcin
I find another solution. Thanks to answer of #munstrocity regarding changing cheap-module-eval-source-map to eval-source-map. Unfortunately, this change didn't fix for me my styles in Chrome Dev Tools but give me good point to check.
After a bit I found, that changing cacheBusting: true, to false in config/index.js help to solve that and now it's possible to change style in Chrome Dev Tools.
// file: config/index.js
...
// If you have problems debugging vue-files in devtools,
// set this to false - it *may* help
// https://vue-loader.vuejs.org/en/options.html#cachebusting
cacheBusting: false,
...
Hope this will help anyone! :)
I've encountered the issue as well, and I was able to prevent this by disabling CSS Source maps in development. I'm still looking into why this only happens on Chrome, but at least we can start looking there. I don't believe this is a Webpack issue.
-- Updated --
I simply changed the devtool to "eval-source-map" in my config/index.js file and everything works.
file: config/index.js
...
// https://webpack.js.org/configuration/devtool/#development
devtool: 'eval-source-map'
...
I had this issue, but only when I had multiple blocks in one component.
E.g.,
<style scoped>
...
</style>
<style>
...
</style>
I couldn't work out the exact cause, except I noted that I could see that the sources devtools tab only ever shows one inline style block, so figure there's some fragile trickery there. My quick workaround was to simply move at least one of the style blocks into its own file.
<style scoped>
...
</style>
<style src="./my-component.unscoped.css"></style>
I don't know why this worked. Hope it helps someone.
Inside your webpack config file you can try to enable source map for your sass loader configuration.
You need to edit your file as follow:
module.exports = {
css: {
loaderOptions: {
sass: {
sourceMap: true
}
}
}
}
For the past two hours I've been trying to figure out a strange behavior when trying to override bootstrap in Django.
At the beginning, without any custom css file, the result was this:
Then I created a custom css file: my_site/css/master.css
.index-jumbotron {
background-color: #006DB0;
}
#main-title {
text-align: center;
color: white;
}
It resulted in this:
So far, so good.
But now, if I change anything on that same file (even when putting !important and taking good care of the specificity system), the result is always the same as the image immediately above.
However, when I indicate my template to point to another file my_site/css/master2.css or css/master.css, indeed the result is as I would have expected:
I can't get my head around this. Do you have any idea? Do you know if the package django-bootstrap3 could have anything to do with that? I installed it in between my two different version of the custom css file.
Looks like a browser caching issue - did you say 'disable cache' in the developer toolbar (network tab) of your browser? This is usually the easiest solution.
Another option is to open the styles file in your browser and hit 'ctrl+r' to force reload of the css file.
I have a website, where we are using a tool to minimize and compress css code. It is called JCH, it is a plugin for Joomla, I think you can use it on Drupal too. I have an issue this css code:
#sp-user3 .help-menu .nav.menu :not(.user-menu){
display: inline-flex;
}
It is being converted to:
#sp-user3 .help-menu .nav.menu:not(.user-menu){display:inline-flex}
As you can see ".nav.menu :not" is converted to ".nav.menu:not" which causes the css rule to not be applied as intended.
This can be an error on the tool. How can i rewrite it or add a character to avoid that confusion? any ideas are welcome.
This is indeed a bug, and this is not the first time I encountered it.
The StackSnippet editor on this site used to have the very same bug in its Tidy button. See my bug report. It was fixed soon after.
So you can file a bug report with JCH and then wait for it to be fixed as well.
Meanwhile, you can insert a * before the : in the CSS as a workaround.
:not() is a shorthand for *:not() anyway, so you won't be changing the meaning of the selector, just writing out in full what was implied.
It's a definitely tool issue, web minifiers like Minify generating correct code.
#sp-user3 .help-menu .nav.menu :not(.user-menu){display:inline-flex}
I am using VS code for a project using CSS Grid and CSS Modules. However when I try something like this
.loginRegisterDiv {
composes: loginDiv;
margin: 0px;
width: 100%;
}
I get an error saying composes "unknown property" for composes. Plus I am using css grid and there does not seem to be any intellisense for this in VS code. Do I need to install an extension?
I am using rallycoding rulesets.
You can add to the VSC CSS linter an exception to the rule css.lint.unknownProperties (or set this to ignore). Open the VSC settings, search for css.lint.validProperties and add 'composes' to the list. The error/warning will go away.
This works to me, in your settings.json file add "css.lint.validProperties": ["composes"],
I use extensions to help with this particular problem. The extension system is excellent in VS Code, and there are a lot of really high quality extensions built by the community that greatly improve the quality and feature set of the editor.
Here are a few extensions that I use for writing SASS in VS Code. One or a couple of these should fix the problems you are having (and maybe even a few you didn't know you were having).
SCSS Grammar Extended by Danny McGee
Features:
Fixes content and cursor property names being tokenized as tag selectors
Fixes background being tokenized as an invalid/deprecated keyword in certain contexts
Fixes color being tokenized as a property value keyword instead of a property name in certain contexts
null and boolean values tokenized as language constants
BEM-style __element and --modifier fragments tokenized as class names
Added recognition for Angular-specific pseudo-selectors :host-context and ::ng-deep
Sass by Syler
Features:
Upgraded syntax highlighting
AutoCompletions / Intellisense
Formatter
CSS Modules Syntax Highlighter by Andrew Leedham
Features:
#value variable decleration: regular and namespaced.
composes: attribute: local and imports.
:global and :local pseudo classes.
SCSS IntelliSense by mrmlnc
Features:
Code Completion Proposals (variables, mixins, functions)
Hover (variables, mixins, functions)
Code navigation
Install one or several of those in VS Code, restart the editor, and then let me know if that doesn't fix your issue.
To make the VS Code recognise these custom CSS directive/properties, you can provide custom data for VS Code's CSS Language Service as mentioned here - https://github.com/Microsoft/vscode-css-languageservice/blob/master/docs/customData.md.
Create a CSS custom data set file with the following info. Place it at location .vscode/custom.css-data.json relative to the project root.
{
"version": 1.1,
"properties": [
{
"name": "composes",
"description": "css modules compose"
}
],
"atDirectives": [
{
"name": "#value",
"description": "css modules value import"
}
],
"pseudoClasses": [],
"pseudoElements": []
}
Now, if you don't have already, create a .vscode\settings.json file relative to project root. Add a field with key "css.customData" and value as the path to custom data set. For example,
{
"css.customData": ["./.vscode/custom.css-data.json"]
}
Now, you will no longer get "Unknown property" warning. When you hover over "composes", you will see the description you set for it in custom.css-data.json
A similar issue has been raised to the vs code team and has not been addressed yet:
https://github.com/Microsoft/vscode/issues/13003
I am experiencing an issue with production build version of the Sencha Touch based application not being able to apply styles properly in IE10 and Chrome.
Steps to reproduce:
Main.js
Ext.define('Lab.view.Main', {
extend: 'Ext.Panel',
xtype: 'main',
requires: [
],
config: {
tabBarPosition: 'bottom',
items: [
{
xtype: 'panel',
cls: 'MyFirstLogo',
itemId: 'firstLogo'
} ]
}
});
SCSS file - app.scss
.MyFirstLogo{
height: auto !important;
min-height: 100px;
min-width: 404px;
padding: 0px;
background-image:url(../../resources/images/test1.jpeg);
background-repeat:no-repeat;
background-position: left;
}
Make sure the background image URL is like this in resources/sass/app.scss - ../../resources/images/test1.jpeg.
Run "sencha app build production" in project root (Lab/)
Access the application in IE10 64bit (Win 7) : http://localhost/lab/build/production/Lab/
Images are not shown at all in IE10. However, when trying this in Chrome it works well. Chrome somehow is able to convert the ../../resources/images/test1.jpeg to http://localhost/lab/build/production/Lab/resources/images/test1.jpeg but IE10 doesn't do it and fails to show the image. This way it also works in my local development environment as it goes with my project structure.
In order to make it work in IE10, I have changed the image URL from ../../resources/images/test1.jpeg to resources/images/test1.jpeg (This actually makes sense as resources/ directory is in the project root) in resources/sass/app.scss and rebuild it for production. In this case image starts to appear in IE10 but now when I use Chrome - Image does't show up and Chrome is trying to retrieve the image from this URL which in not right: http://localhost/lab/build/production/Lab/resources/css/resources/images/test1.jpeg, and it fails. This way it DOES NOT also work in my local development environment.
This issue happens for other resources as well like "fonts".
Could you please help me understand what's going on here with Sencha's Production Build version not working in both IE10 and Chrome at the same time? Is this this bug with Sencha Touch or Chrome or I am missing something here?
It turns out to be the known bug in Sencha Touch as confirmed by the Sencha people. Check this link: http://www.sencha.com/forum/showthread.php?266275. Thanks #peter and #arthurakay for you help. If I need a workaround or further discussion on this. I will start the discussion again. Thanks guys!
Why are you going back so many directories in the relative file path?
Whether you're in development or production, the CSS file lives at:
{app_root}/resources/css/app.css
Assuming your images are here:
{app_root}/resources/images/
...then your filepaths should look like this:
background-image:url(../images/test1.jpeg);
FYI I'm assuming Touch 2.3 and Cmd 4.0.x since you didn't specify.
The address you access the application (in any browser) becomes the page base address. In your case it's http://localhost/lab/build/production/Lab/
You can confirm this by printing alert(document.location.href).
Check the trailing slash, please.
Address ../../resources/images/test1.jpeg then means http://localhost/lab/build/production/Lab/../../resources/images/test1.jpeg and translates to incorrect
http://localhost/lab/build/resources/images/test1.jpeg
Modify the relative address to ../resources/images/test1.jpeg to get
http://localhost/lab/build/production/resources/css/resources/images/test1.jpeg
You can always verify the resulting address by entering it to the browser's address bar.
Both IE and Chrome translate paths correctly as this is their basic task.
I have found a workaround to make images/icons visible on both IE10 and Chrome.
Here, CSS property given for any given class containing "background-image" should contain working URL's for both IE10 and Chrome as follows :
.menuHome {
background:url(resources/icons/menu/Home.png),url(../icons/menu/Home.png) no-repeat center;
}
Here both URL's are present in the CSS property. So IE10 will fetch image from 1st URL and Chrome will fetch image from 2nd url.