gojs开发环境去除水印

在vue.config.js下去做修改

引入功能的js文件

const BuildConfigPlugin = require('./plugins/config.js')

module下做如下配置操作

module.exports = {

chainWebpack: (config) => {

config

      .when(process.env.NODE_ENV === 'development',

        config => {

          config.devtool('cheap-source-map')

          config.plugin("buildConfig").use(BuildConfigPlugin, [

            {options: true}

          ])

        }

      )

}}

BuildConfigPlugin 配置下的js代码如下

const fs = require('fs')

const path = require('path')

const file = path.join(__dirname, '../node_modules/gojs/release/go.js')

// const file = path.join(__dirname, '../src/utils/gojs.js')

function buildConfig(){

    fs.readFile(file, 'utf8', function(error, data) {

        if (error) throw error;

        let hasMatch = false;

        let content = data.replace(/[\w\W]{8}7eba17a4ca3b1a8346[\w\W]{31}/gi, function (match) {

            if (match) hasMatch = true;

            return 'function() {return true;}'

        })

        if(!hasMatch) {

            content = data.replace(/[^\)^\{}]*7ca11abfd7330390[^;]*/gi, function (match) {

                let arr = /\]\(([^\,]+)/.exec(match);

                return arr && arr.length>=1 && arr[1];

            })

        }

        fs.writeFile(file, content, 'utf8', (error) => {

            if (error) throw error;

        })

    })

}

class BuildConfigPlugin {

    apply(compiler) {

        compiler.hooks.afterPlugins.tap(

            'BuildConfigPlugin', (stats) =>{

                buildConfig()

            }

        )

       

    }

}

module.exports = BuildConfigPlugin

如上操作就可以去除开发环境下的gojs的水印

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值