Cannot view scss files while working with Ionic on dev tools - ionic-framework

I'm trying out some very basic Ionic tutorials from Ionic website (Ionic Tutorial), and i want to be able to view and modify scss from dev tools.
The app functions correctly, css classes i've added in scss files work correctly as well but i see a main.css file instead of the foo.css from which it was compiled. I can even view typescript files on dev tools and debug, which means source map for js->ts is working. It's the css-> scss that's not working.
I can see these files on www/build
main.js
main.map.js
main.css
main.map.css
Which means the source map is generated correctly.
I have also enabled css source maps in chrome from
- DevTools -> Settings ->Sources -> Enable CSS source maps

I would mark this as duplicate but it seems like i cannot. Answer can be found on this SO postenter link description here. Basically,
You'll need to extend your sass.config.js file, by default source mapping for sass is disabled.
config/sass.config.js:
module.exports = {
sourceMap: true,
}
package.json:
"config": {
"ionic_sass": "./config/sass.config.js",
}
I can verify that this works.

Related

vscode extension development: svelte content not loading in webview after building the vscode extension

I am building a vscode extension by using svelte for webview. I am following https://youtu.be/a5DX5pQ9p5M. But the deployment of extension is not mentioned in the tutorial .
So i am following https://code.visualstudio.com/api/working-with-extensions/publishing-extension.
So after packaging the extension with vsce package and installing the extension the extension doesn't load svelte content but when running in developer mode everything works fine.
I tried creating the package extension multiple Times but still didn't work.
Check if all necessarily files are included via:
vsce ls
(You can also open packaged extensions, they are just ZIP-archives with a different extension.)
If they are not (e.g. src is excluded by default), you probably can create a .vscodeignore file and manually specify what to exclude.
Running extension problems can be inspected via Help > Toggle Developer Tools, usually you will find some errors in the console.
I do not know if debugging forces the extension to load, but if so, make sure you have set the correct activationEvents.

My TailWind CSS Intellisense plugin just isn't working on my VSCode

So the description of the plugin is that it'll display suggestions of classes when am working on the markup, but it doesn't. I've reloaded the plugin countless times. I even restarted vscode and eventually re-installed it.
Of course, I did the npm install tailwind and other utilities needed... I even have my tailwind.config.js file in my project if that helps to answer my question. Thank you.
I'm using tailwindcss in a react app. Tailwindcss Intellisense plugin was not working in my VSCode but then i installed HTML CSS Support extension and now i am getting suggestions of classes.
HTML CSS Support
Its actually a pretty simple fix. open your settings.json file then add this to get the intellisense working on all files
"tailwindCSS.includeLanguages": {
"html": "html",
"javascript": "javascript",
"css": "css"
},
"editor.quickSuggestions": {
"strings": true
}
To fix this issue try using ctrl + space
This is the easiest way I found to get Tailwind IntelliSense to work with .js files to React. You need to do this every time you are adding a new class but it's quicker than checking the documentation every time.
Credit: Reddit
What helped me was to check whether the plugin had any issue loading. You can do this by checking the output view:
CTRL + SHIFT + P to bring up the command palette
Search for "Output: Focus on Output View"
In the Output View, search for tailwindcss-intellisense
For me the error was
Failed to initialise: ReferenceError: defaultTheme is not defined - I was missing a require for the defaultTheme.
for me..
I installed 'IntelliSense for CSS class names in HTML', 'HTML CSS Support', 'CSS Peek' all together with reinstalling..
It works now.
To anyone still facing this problem, I found that the tailwind extension doesn't recognize your tailwind.config.js file if it's untracked (not added to source control). Once I added the file and did git commit, the extension worked.
if you're using nuxt/tailwind module be sure to init tailwind.config.js as doc says.
npx tailwindcss init
then restart the vs-code. it should automatically be active.
I'm using tailwind + create-react-app + typescript, I solved it by changing the extension setting "Tailwind CSS: Include Languages", to {"plaintext": "ts"}.
I don't know why it didn't work in the first place, it was working for my other projects.
Just go to the
Tailwind CSS IntelliSense
extension in Vs code
and install the old version and reload it.
It works.
This is the solution for autosuggestion on typing. So you don't need to use space+ctrl or just space. In case anyone needs it.
editor.suggest.snippetsPreventQuickSuggestions: false
Without pressing ctrl-space, I just need to press space and the classes will come out.
I am using Tailwindcss with Django.
Facing the same issue where Tailwindcss IntelliSense plugin is already installed and autocomplete wasn't working.
Finally I got the perfect solution.
For most projects (and to take advantage of Tailwind’s customization features), you’ll want to install Tailwind and its peer-dependencies via npm.
npm install -D tailwindcss#latest postcss#latest autoprefixer#latest
In my case the postcss and autoprefixer was not installed.
You can run the above command and npm will take care of it if you have Tailwindcss already installed.
Also don't forget to put these lines in your settings.json in VSCode (Recommended VS Code Settings for Tailwind CSS IntelliSense):
// VS Code has built-in CSS validation which may display errors when using Tailwind-specific syntax, such as #apply. You can disable this with the css.validate setting
"css.validate": false,
// By default VS Code will not trigger completions when editing "string" content, for example within JSX attribute values. Updating the editor.quickSuggestions setting may improve your experience:
"editor.quickSuggestions": {
"strings": true
},
// This setting allows you to add additional language support. The key of each entry is the new language ID and the value is any one of the extensions built-in languages, depending on how you want the new language to be treated (e.g. html, css, or javascript):
"tailwindCSS.includeLanguages": {
"plaintext": "django-html"
},
I disabled and re-enabled the plugin. Wait a bit for it to re-indexing. And it works.
I fixed it by creating a tailwind.config.js file with the help of npx tailwindcss init command. I was following tutorials of net ninja (youtube channel) and he mentioned this solution.
If you are using tailwind with react, typescript, javascript, styled-components, and twin-macro, you have to add classRegEx manually to get the IntelliSense
To achieve this edit the user settings as below
"tailwindCSS.experimental.classRegex": [
"tw`([^`]*)",
["classnames\\(([^)]*)\\)", "'([^']*)'"]
],
For more information and to see what classRegEx should use with other techs read this
This setting is good working for react.js application
{
"tailwindCSS.experimental.classRegex": [
"class:\\s*\"([^\"]*)\""
],
"emmet.triggerExpansionOnTab": true,
"tailwindCSS.emmetCompletions": true,
"editor.quickSuggestions": {
"strings": true
}
}
Update VS Code
I had the same issue I just fixed it by updating VS Code.
At first, write in your project npm install tailwindcss postcss-cli autoprefixer, Then write in your terminal npx tailwind init, at last write npm tailwind"postcss.config.js and then write in the file:
module.export = { plugins: [require('tailwindcss'), require('autoprefixer')]};
last step u can build your tailwindcss in packagein accordance with the package.json.
For more info u can visited this link.
Running Tailwind CSS: Show Output from View -> Command Palette (or Ctrl + Shift + P), as suggested here, unveils that the "Tailwind CSS IntelliSense" plugin is looking for a proper npm installation of the module tailwindcss.
Solution: We can therefore fix the issue by simply running
npm install tailwindcss
within our project directory.
Make sure that you open the project from its root folder. I happened to me that there were multiple package.json files in the a different folder, the VS code plugin will be confused with tailwindcss path.
Just open the Explorer view and you should see one and only one package.json file and tailwindcss is listed as the dependencies.
For React project with .tsx file, adding this works for me.
// .vscode/settings.json
{
"tailwindCSS.includeLanguages": {
"typescriptreact": "html"
}
}
Credit: https://github.com/tailwindlabs/tailwindcss-intellisense/issues/72#issuecomment-674386396
for me helps installed plugin IntelliSense for CSS class names in HTML
Rails erb - Custom class name completion contexts
Add to settings (ctrl + shift + p)
"tailwindCSS.experimental.classRegex": [
"class:\\s*\"([^\"]*)\""
]
See github issue reply
I did Smit #Barmase solution but also added "plaintext" and "tsx".
Now everything works when I hit space after previous class.
In my case, the code completion not working without the start tag >.
Not work:
<div class=""
Work:
<div class="">
My best practice
Strictly speaking, it doesn't work without the start tag >. But My best practice is to write the closing tag and then write the class.
First write:
<div class=""></div>
Second write:
<div class="w-10"></div>
I solved the problem only by deleting the space between the equal sign and and quote.
So instead of writing className= "tailwind classes..." write className="tailwind classes...". I hope that this answer will help.
Had the same issue with Intellisense, the output in VSCode for the "TailWind CSS IntelliSense" had
[Error - 1:36:36 PM] Tailwind CSS: Cannot set property 'parent' of undefined
TypeError: Cannot set property 'parent' of undefined
This seemed to be coming from the postcss-nested plugin, however after reading a few other SO posts on the similar issue it actually came down to my setup.
The main project folder was failing to parse a file that existed inside a sub-project (td;lr. using a wordpress theme git repo that is build with the template as the root).
Since the original setup to process the TailWind wasn't needed, I noticed that the root project was TailWind v3, while the sub-project was TailWind v2. After removing the base package.json dependancies Intellisense kicked in picked up the [sub-project] tailwind config, postcss and tailwind version.
Not sure if that might be similar to your setup, but what is suggested is checking the package versions, and that your tailwind config files (if any) are setup right.
The moment you fix it, you should immediately be able to see in the Output tab for "TailWind CSS IntelliSense" something similar to the following....
Found Tailwind CSS config file: /.../tailwind.config.js
Loaded postcss v8.3.0: /.../node_modules/postcss
Loaded tailwindcss v2.2.0: /..../node_modules/tailwindcss
Hope there's something you can take away from this. :)
The extension HTML CSS Support extension is not the correct way to go. As specified in the official installation section of the detail page in the extension page in VSC.
In order for the extension to activate you must have tailwindcss installed and a Tailwind config file named tailwind.config.js or tailwind.config.cjs in your workspace.
so adding a file (even empty) named tailwind.config.js or tailwind.config.cjs at the root of your app will make it work.
My issue was with the tailwind.config.js. Since I followed the Tailwind installation step by step, I put the content as
content: ["./src/**/*.{html,js}"]
While I had no src folder, rather my html file was at the root. So I changed it to below and the IntelliSense started working.
content: ["/*.{html,js}"]
So just in case someone is making this silly mistake like me :)
How to get it working with denoland's Fresh framework
Check that the extension is not loading by opening the OUTPUT tab of the console and verifying that the dropdown menu has an entry for Tailwind CSS IntelliSense.
If it does not figure there you need to make a blank tailwind.config.js file at the root directory.
This file is completely redundant with Deno, but required by the extension.
If it still does not help, try other methods shown in this thread. With the extension loading latest version of it does work on with setup.

How do i make working custom css in ionic?

I've added custom css in ionic+angular which is working absolutely perfect with browser and its devices, but while i am generating apk for android device custom css is not working in android.
I am running this command to generate APK : ionic cordova run android
For more information i attached ionic version and index html screenshot.
version screenshot
Index.Html screenshot
First, make sure that "appStyle.css" file is written with S uppercase. Windows machines are case insensitive and Linux Machines (Android) are case sensitive.
Second, make sure that you're changing the index.html at src folder, not at www. Because www is the generated files and it is rewritten every build.
At last, as Abdul said in the comment, you should import your CSS files at app/app.scss.
#import '../assets/css/font-awesome.min';
I recommend you to put the css files outside from assets, which is recommended only static files, like images.

Utilizing a component, from GitHub, in my Vue project. (I'm a complete beginner)

This semester, I began learning Vue. Our first "assignment" for the Vue phase was to follow along with, and complete, the instruction provided by a YouTube video from Traversy Media. This video was great to follow, evident that I was able to complete its objective with little difficulty. However, I don't feel that I quite understand the relevance of each file within a Vue project, such as index.js, index.html, *.vue.
I've found a few videos which create a component and then utilize that component. However, I feel completely lost when downloading a component, specifically: 'Vue-Accordion' from github to use as my navigation in conjunction with vue-router. The vue-accordion instructions simply state to add specific code, but doesn't say to which file I should add this code.
I've hacked at it by guessing/assuming a file that I figured relevant to the task, such as app.vue, index.js, and index.html... to no avail. Certainly, I think that a better understanding of a Vue Project's file-structure/hierarchy could give me a better feel in knowing exactly what files are relevant to any task-at-hand that I may have.
Alright so schools in session (sorry if I explain too basic stuff at times, just trying to be thorough).
Here's the basic structure for a Vue project using vue init webpack-simple my-project:
src/
assets/
logo.png
App.vue
main.js
.babelrc
.gitignore
index.html
package.json
README.md
webpack.config.js
The src folder contains all the source files of your project.
The src/assets folder contains all your assets, primarily images.
App.vue is the first "view" of your app.
main.js is the main script of your project where you configure and run Vue. This is where you load anything that should exist in the global scope of your app.
.babelrc configures how the babel tool should syntax check your code.
.gitignore tells Git to ignore certain files from committing.
index.html is the page that's sent to the clients browser. This is where we load the main.js file and put any and all meta data you need (unless you use e.g. vue-meta to handle it there instead). Note that <div id="app"> html tag, this is where all your Vue files get mounted to.
package.json is our npm configuration file. When you run e.g. npm install --save component-from-npm-name it's saved here so you can just run npm install later to get all the dependencies of your project.
README.md is a documentation file in the Markdown language format. It's displayed as the frontpage of your project on e.g. Github or Gitlab.
webpack.config.js is a Node.js file that is responsible for running Webpack on your project. Vue can be used without Webpack but I don't recommend it. You can run node webpack.config.js directly to build your project. This file is your build script, you configured this to handle the build process of your project.
So, armed with this information, lets get to your question.
How do you load a component in Vue.js?
Run npm install --save vue-accordion (note that while the source code is hosted on Github, the package is downloaded from here: https://www.npmjs.com/package/vue-accordion)
In your index.js file, which is responsible for loading things to your Vue app in the global context, you do as the Github page tells you and first import {vueAccordion} from 'vue-accordion', then run Vue.component('vue-accordion', vueAccordion) to register it in the global context.
That's all there is to it. index.jsis your entry point for your Vue app, while webpack.config.js is your build script.
There is however an alternative solution to loading components. In the previous variant we loaded it in index.js to load it in the global context, i.e. you can use the component now anywhere in your app, but what if you only want to load it on an as-is-needed basis (you'd wanna do this for performance reasons)?
Well, in your App.vue file you have a <script> tag where you can configure things in just that Vue component (all .vue files are Vue components, even if you call them routes, pages, views or whatever to indicated their purpose). In order to load a component not in the global context, but the component context, you'd do the following in App.vue:
<script>
import Accordion from 'vue-accordion';
export default {
components: {
'vue-accordion': Accordion
}
</script>
Tips...
This is just one setup for a Vue project. A Vue project can be as simple as just loading Vue as a script to your static index.html file, then you can have a much more annoying setup with regular javascript files, but that's dumb and inefficient. So, a proper project has a Node.js file to run Webpack. Depending on how you configure Webpack your project can act quite differently from any other Webpack project.
Read up more on how Webpack works so you can have a project structure that makes sense for you.
Take a look at Nuxt, it's essentially a collection of other projects (primarily Vue and Webpack) that simplifies the making of a powerful Vue project. You can sit and set up your own Vue project and all the tools yourself and get the same result, but Nuxt makes it simpler for you to do.
To install a specific GitHub repository as a node dependency.
Actually, it doesn't matter if it is a dependency for Vue or React
it is related to setting in the package.json dependency from a GitHub source.
You need to modify your package.json file. In the dependencies section, add the package name as the property name and, as a value, the username of the repository in GitHub and the repository directory.
e.g
"dependencies": {
"#zeratulmdq/vue-accordion": "zeratulmdq/vue-accordion"
}
and then to import the component
import VueAccordion "#zeratulmdq/vue-accordion"
It is not related to your desired repository, but just in case the selected repository package.json file does not point to the correct main property, it will not load the component, so you will need to point to the specific component file to import, e.g:
import VueAccordion "#zeratulmdq/vue-accordion/src/index.js"
or
import VueAccordion "#zeratulmdq/vue-accordion/src/App.vue"

How to have google chrome debug dev tools see coffeescript files?

i'm setting up an environment to debug coffeescript file.
I'm using an IDE, webstorm, that genrates both .js file and .map from original .coffee file, from coffeescript default compiler.
So I endup with 4 files all in same folder:
main.html, aa.coffee, aa.js, aa.map.
in main.html I include the js file.
The JS files contains:
// Generated by CoffeeScript 1.6.3
var my;
my = 1;
alert(my);
/*
//# sourceMappingURL=aa.map
*/
Very simple. When loading main.html it correctly popup the alert.
Now when I open google dev tools / source, where I see the tree of my files, I see the html file and the js file. But it's IMPOSSIBLE to have the .coffee file appear, although correctly referenced as you can see above. Of course, I did enable sourcemap in dev tools settings. I wathed several video tutorial and I did all step for the coffee file to appear.
Here is content of the 2 other files:
the .coffee :
my = 1
alert my
the .map:
{
"version": 3,
"file": "aa.js",
"sourceRoot": "",
"sources": [
"aa.coffee"
],
"names": [],
"mappings": ";AAAA,EAAA,EAAA;;AAAA,CAAA,CAAA,CAAK;;AACL,CADA,CACA,GAAA"
}
Do you have an idea why the source map process doesn't work on chrome dev tools ?
edit: I've now changed my mind on all this and don't use source-map debugging at all. First, it was generally flaky. Second, if I'm not writing JS I should at least be able to read it so I always debug in js.
First, keep in mind that source map debugging is flaky in Chrome right now. A couple things you can try:
Put a debugger statement in your code. I've noticed that the debug is very flaky -- about 10% of the time it just won't stop on breakpoints.
Open the coffee file directly by pressing Ctrl O in the sources pane then place breakpoints or use debugger statements.
Figure out why "sourceRoot": "", is empty. It's possible that that just means that the source file will be in the same directory as the js file (seems likely). My coffee files are in a different directory so they have a sourceRoot entry.
Generate the source maps with grunt or coffeescript. This seems unlikely to have an effect though.
I'm betting #2 will do it.