我正在使用和gulp4
代理本地 Wordpress 安装。我的 Apache 和数据库正在使用. 该项目位于我桌面上的文件夹中,而不是 in文件夹中browsersync
gulp-connect-php
xampp
xamp\htdocs\dev
当我运行gulp
Wordpress 代理时,它会启动并且可以通过启动浏览器来访问:http://localhost:3000/
从那里我可以登录到 Wordpress 管理员:http://localhost:3000/wp-admin
然后我被重定向到 Wordpress 仪表板:http://localhost:3000/wp-admin
从仪表板中,我从左侧菜单中单击的任何链接从 URL 中删除“wp-admin”,因此找不到所需的页面。例如,如果我要单击“插件”,我将被定向到http://localhost:3000/plugins.php
而不是http://localhost:3000/wp-admin/plugins.php
端口8001
是 xampp 将 php.exe 设置为的端口。
我的 Wordpress siteurl 和 homehttp://localhost:8001
在数据库中安装时都默认设置为。
gulpfile.js
//establish vars
var gulp = require("gulp"),
sass = require("gulp-sass"),
postcss = require("gulp-postcss"),
autoprefixer = require("autoprefixer"),
cssnano = require("cssnano"),
sourcemaps = require("gulp-sourcemaps"),
connect = require('gulp-connect-php'),
browserSync = require("browser-sync").create(),
imagemin = require('gulp-imagemin'),
concat = require('gulp-concat'),
rename = require("gulp-rename"),
fs = require("fs"),
uglify = require('gulp-uglify-es').default;
//setup the proxy server and browser-sync
connect.server({
base:'./dist',
port:8001,
keepalive:true
});
browserSync.init({
proxy: "localhost:"+8001,
baseDir: "./src",
open: true,
notify: false
});
// Tell gulp which files to watch to trigger the reload
gulp.watch([
'src/**/*.php'
]).on('change', update);
var update = gulp.parallel(
scss,
js,
moveTheme
);
//compress files, move theme to distribution folder, etc
function scss(){...}
function js(){...}
function moveTheme(){...}
初始化后,gulp 日志
[Browsersync] Proxying: http://localhost:8001
[Browsersync] Access URLs:
-------------------------------------
Local: http://localhost:3000
External: http://192.168.1.17:3000
-------------------------------------
UI: http://localhost:3001
UI External: http://localhost:3001
-------------------------------------