0.2.0 • Published 8 months ago

babel-plugin-client-variable v0.2.0

Weekly downloads
-
License
ISC
Repository
-
Last release
8 months ago

babel-plugin-client-variable

安装

使用 npm 安装

npm install babel-plugin-client-variable -D

使用

在 babel.config.js 中添加

+  const clientVariable = require('babel-plugin-client-variable');

module.exports = {
+  plugins: [
+    clientVariable
+  ]
}

使用后效果

使用前打包编译成

function name1() {
  const aaa = document.querySelector('body')
  console.warn(aaa)
}

name1()

使用后打包编译成

function name1() {
  const aaa = process.client ? document.querySelector('body') : {}
  console.warn(aaa)
}

name1()
0.2.0

8 months ago

0.1.1

8 months ago

0.1.0

8 months ago