1.0.9 • Published 1 year ago

cuiplus-ifdef v1.0.9

Weekly downloads
-
License
ISC
Repository
-
Last release
1 year ago

Getting started

$ npm install cuiplus-ifdef

Usage

vite.config.js

import { defineConfig, loadEnv } from 'vite'
import conditionalCompile from "cuiplus-ifdef";
export default defineConfig(({ command, mode }) => ({
    plugins: [
        conditionalCompile(loadEnv(mode, process.cwd()).VITE_PROJECT_TYPE),
        vue(),
    ],
}))

.env.development

VITE_PROJECT_TYPE = PROJECT_A

use

//#ifdef PROJECT_A
console.log('only show in PROJECT_A')
//#endif

//#ifndef PROJECT_A
console.log('only show not in PROJECT_A')
//#endif

.env.development (use '-' to support child)

VITE_PROJECT_TYPE = PROJECT-A

use

//#ifdef PROJECT-A
console.log('show this')
//#endif

//#ifdef PROJECT
console.log('allow show this')
//#endif

//#ifndef PROJECT-B
console.log('allow show this')
//#endif

//#ifndef PROJECT-A
console.log('not show')
//#endif

//#ifndef PROJECT
console.log('not show')
//#endif

//you can allow use "<!--#ifdef [NAME]--> and <!--#ifndef [NAME]--> in html
1.0.9

1 year ago

1.0.8

2 years ago

1.0.7

2 years ago

1.0.6

2 years ago

1.0.5

2 years ago

1.0.4

2 years ago

1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago