D
D
dominy2021-07-30 11:13:09
Sass
dominy, 2021-07-30 11:13:09

How to create define for one vue document?

Hello,
I have a Vue component file structure like this

<template>...</template>
<style lang="scss" scoped></style>
<script></script>

But I had a need to do #define SOMETHING 1;
and this SOMETHING must be available everywhere in this vue file
so that you can do this
$my-scss-var: SOMETHING;
or this
let myJsVar = SOMETHING;
or even this
<div>SOMETHING</div>
only this SOMETHING must exist within this vue file - are there similar plugins for webpack?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Maxim Morev, 2021-07-30
@SeaInside

Apparently, you just need to replace one line with another?
In webpack, such transformations are done using loaders, for example, string-replace-loader may suit you (I don’t use it myself, but according to the text of the task - why not).
But in general, this is strange, both IDE and linters will swear at SOMETHING that does not exist in this context, and in general it is some kind of magic, and the less magic, the better.
If you give a specific example, rather than an abstract SOMETHING, then it will be clearer what you want and probably a more obvious solution can be advised.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question