Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Open certain files in a workspace as read-only in VS Code

I am working on a typescript project using Visual Studio Code. I have a workflow in which a gulp task will copy a code into a target folder. Copied file will be used by the respective files in the destination folder using imports.

eg. Folder structure

common

server/src

client/src/app

All the files in common will be copied into server/src/common and client/src/app/common

In the server/src/test.ts file, I will add reference to the copied files as follows.

import { CommonClass } from './common/commonClass'

Everything works perfectly fine. The problem occurs when I decide to go to the definition of the imported class 'CommonClass' by pressing F12.

This will open up the copied file and not the one in the source "common" folder. I would like to restrict this opened file to be in read-only mode, so that I do not make changes. The changes will be replaced by the gulp task in time.

Is there any way to achieve this using some extensions or workspace settings in Visual Studio Code?

Tried to use gulp-chmod to make the destination files are read-only, but ran into issue when the typescript compiler is trying to access them during build.

like image 618
rmchndrng Avatar asked Sep 09 '25 11:09

rmchndrng


1 Answers

VSCode 1.79 introduces a feature to mark specific files and folders as read-only

like image 156
Vladyslav Zavalykhatko Avatar answered Sep 11 '25 01:09

Vladyslav Zavalykhatko