vue-cli-plugin-docker-nginx-diff-proxy
Advanced tools
+1
-1
@@ -28,3 +28,3 @@ { | ||
| }, | ||
| "version": "1.0.2" | ||
| "version": "1.1.2" | ||
| } |
+18
-22
@@ -15,3 +15,2 @@ const FS = require('fs'); | ||
| str = str.replace(regExp, targetStr); | ||
| console.log(str); | ||
| FS.writeFile(filePath, str, function (err) { | ||
@@ -26,3 +25,3 @@ if (err) return err; | ||
| //读取文件,并且替换文件中指定的字符串 | ||
| let replaceFile = function(filePath,sourceRegx,targetStr){ | ||
| /*let replaceFile = function(filePath,sourceRegx,targetStr){ | ||
| FS.readFile(filePath,function(err,data){ | ||
@@ -38,3 +37,3 @@ if(err){ | ||
| }); | ||
| } | ||
| }*/ | ||
| //向文件倒数第二行插入 | ||
@@ -55,3 +54,3 @@ let resertFile = function (filePath, targetStr) { | ||
| apply (compiler) { | ||
| compiler.hooks.compilation.tap(ID, compilation => { | ||
| var emit = (compilation, callback) => { | ||
| //nginx,找到*.conf文件 | ||
@@ -73,28 +72,25 @@ const nginxPath = './nginx'; | ||
| let isFile = status.isFile();//是文件 | ||
| let isDir = status.isDirectory();//是文件夹 | ||
| if (isFile) { | ||
| if (item.match(new RegExp(/\.conf$/))) { | ||
| Object.keys(this.env_prefix).map((key) => { | ||
| if (item.includes(key)) { | ||
| // replaceFile(path, /http\:\/\/localhost\:8080/g, this.env_prefix[key]); // ^ 以什么开头 | ||
| // replaceFile(path, /location \/proxy/g, `location ${this.proxy_prefix[key]}`); // ^ 以什么开头 | ||
| const text = `location ${this.proxy_prefix}` | ||
| const insertText = ` ${text} { proxy_pass ${this.env_prefix[key]} }\n`; | ||
| taskConfFile(path, insertText, text); | ||
| // resertFile(path, insertText); | ||
| } | ||
| // let isDir = status.isDirectory();//是文件夹 | ||
| if (isFile && item.match(new RegExp(/\.conf$/))) { | ||
| const prefix_key = Object.keys(this.env_prefix).find((key) => { | ||
| return item.includes(key); | ||
| }); | ||
| // replaceFile(path,/console\.log\(\"0function0\"\)/g,"zyk"); | ||
| } | ||
| const text = `location ${this.proxy_prefix}` | ||
| const insertText = `${text} { proxy_pass ${this.env_prefix[prefix_key]} }\n`; | ||
| taskConfFile(path, insertText, text); | ||
| } | ||
| if (isDir) { | ||
| console.log("文件夹:" + item); | ||
| } | ||
| }); | ||
| callback(); | ||
| }); | ||
| } | ||
| }); | ||
| }) | ||
| } | ||
| if (compiler.hooks) { | ||
| var plugin = {name: ID}; | ||
| compiler.hooks.emit.tapAsync(plugin, emit); | ||
| } else { | ||
| compiler.plugin('emit', emit); | ||
| } | ||
| } |
16520
-2.2%156
-3.11%