You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I edited extension.js locally because it doesn't work on my setup. You are not sending to the browser using http protocol so file is not rendered as a web page.
I have apache root folder as g:/xxx/ and each website is in a subfolder of the apache root folder.
in vscode I open a root folder of any particular website I want to edit and then I want to send that websites index.php to the browser.
So each of my websites is in its own root folder
g:/xxx/rootfolder
I have also taken out the file type check so I can send any file type to browser, PHP,ASP,HTM,HTML etc
my code for extension js is now as follows:
'use strict';
var vscode = require('vscode');
var path = require("path");
var open = require('open');
function activate(context) {
var disposable = vscode.commands.registerCommand('extension.viewInBrowser', function () {
var editor = vscode.window.activeTextEditor;
if (!editor) {
vscode.window.showWarningMessage('no active text editor!');
return;
}
var file = editor.document.fileName;
var ext = path.extname(file);
var fileUrl = file.replace(/g:(\\|\/)xxx/g, "");
open("http://localhost" + fileUrl);
});
context.subscriptions.push(disposable);
}
exports.activate = activate;
function deactivate() {
}
exports.deactivate = deactivate;
//# sourceMappingURL=extension.js.map
If anyone wants to use this code all you need to do is edit the regex to strip off the path to your webserver root (not your website root folder unless its the same).
i.e. replace /g:(\\|\/)xxx/g
with: /drive:(\\|\/)path-to-webserver-root/g
works for me, YMMV
The text was updated successfully, but these errors were encountered:
I edited extension.js locally because it doesn't work on my setup. You are not sending to the browser using http protocol so file is not rendered as a web page.
I have apache root folder as g:/xxx/ and each website is in a subfolder of the apache root folder.
in vscode I open a root folder of any particular website I want to edit and then I want to send that websites index.php to the browser.
So each of my websites is in its own root folder
g:/xxx/rootfolder
I have also taken out the file type check so I can send any file type to browser, PHP,ASP,HTM,HTML etc
my code for extension js is now as follows:
If anyone wants to use this code all you need to do is edit the regex to strip off the path to your webserver root (not your website root folder unless its the same).
i.e. replace
/g:(\\|\/)xxx/g
with:
/drive:(\\|\/)path-to-webserver-root/g
works for me, YMMV
The text was updated successfully, but these errors were encountered: