🚀 Socket Launch Week Day 5:Introducing Repository Access Permissions and Custom Roles.Learn more
Sign In

webpack-plugin-jscc

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

webpack-plugin-jscc

`webpack-plugin-jscc`是支持代码级的条件编译能力一个插件

latest
npmnpm
Version
0.0.4
Version published
Weekly downloads
60
66.67%
Maintainers
1
Weekly downloads
 
Created
Source

Webpack Plugin For Jscc

简介

webpack-plugin-jscc是支持代码级的条件编译能力一个插件

使用

安装

yarn add webpack-plugin-jscc

常规使用

import JsccPlugin from 'webpack-plugin-jscc'

JsccPlugin的参数说明

参数类型说明默认值
extsArray<string>需要解析的文件['vue', 'js', 'ts', 'css', 'stylus', 'less', 'scss']
valuesObject注入的业务环境标识{_PLATFORM: 'web'}
excludesArray<string>不做处理的文件[/node_modules/]
plugins: [
  new JsccPlugin({
    values: {
        _PLATFORM: 'web', // 匹配业务环境标识
    }
  })
]

条件编译业务书写规则

更多 jscc 高级用法,可以参考 jscc 文档

js/ts:

//#if _PLATFORM==='web'
console.info('【js/ts】 in web')
//#else
console.info('【js/ts】 in other')
//#endif

vue:

<template>
  <div class="view">
    <!--#if _PLATFORM==='web'  //-->
    <HelloWorld msg="Welcome to web!"/>
    <!--#else //-->
    <HelloWorld msg="Welcome to other!"/>
    <!--#endif //-->
  </div>
</template>

css:

/*#if _PLATFORM==='web' //*/ 
.web {
    height: 10px
  }
/*#endif //*/

TODO

  • 单测编写
  • 支持合并配置,而不是覆盖配置

FAQs

Package last updated on 25 Mar 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts