Skip to content

Commit 1fa0ce5

Browse files
committedMar 8, 2020
feat: Add wwwroot folder to project as dist folder
1 parent 1839e7f commit 1fa0ce5

File tree

3 files changed

+47
-21
lines changed

3 files changed

+47
-21
lines changed
 

‎Vagrantfile

+2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
# -*- mode: ruby -*-
22
# vi: set ft=ruby :
33

4+
FileUtils.mkdir_p './wwwroot'
5+
46
Vagrant.configure("2") do |config|
57

68
# Box Settings

‎gulpfile.babel.js

+44-21
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,35 @@
1-
// Initialize modules
1+
// Gulp plugins
22
import {src, dest, watch, series, parallel} from 'gulp';
3-
import yargs from 'yargs';
4-
import sass from 'gulp-sass';
3+
import banner from 'gulp-banner';
4+
import bumpVersion from 'gulp-bump';
55
import cleanCss from 'gulp-clean-css';
6+
import conventionalChangelog from 'gulp-conventional-changelog';
67
import gulpif from 'gulp-if';
8+
import imagemin from 'gulp-imagemin';
9+
import notify from 'gulp-notify';
710
import postcss from 'gulp-postcss';
11+
import prompt from 'gulp-prompt';
12+
import replace from 'gulp-replace';
13+
import run from 'gulp-run';
14+
import sass from 'gulp-sass';
815
import sourcemaps from 'gulp-sourcemaps';
16+
import wpPot from 'gulp-wp-pot';
17+
import zip from 'gulp-zip';
18+
19+
// Other plugins
20+
import pkg from './package.json';
921
import autoprefixer from 'autoprefixer';
10-
import imagemin from 'gulp-imagemin';
1122
import del from 'del';
12-
import webpack from 'webpack-stream';
1323
import named from 'vinyl-named';
1424
import browserSync from 'browser-sync';
15-
import zip from 'gulp-zip';
16-
import pkg from './package.json';
17-
import replace from 'gulp-replace';
18-
import wpPot from 'gulp-wp-pot';
19-
import banner from 'gulp-banner';
20-
import prompt from 'gulp-prompt';
21-
import bumpVersion from 'gulp-bump';
22-
import conventionalChangelog from 'gulp-conventional-changelog';
23-
import notify from 'gulp-notify';
24-
import run from 'gulp-run';
25+
import webpack from 'webpack-stream';
26+
import yargs from 'yargs';
2527

28+
// Configs
2629
const PRODUCTION = yargs.argv.prod;
2730
const server = browserSync.create();
31+
require('dotenv').config();
32+
const dist = `wwwroot/wp-content/themes/${pkg.name}`;
2833

2934
// Browsersync
3035
const serve = done => {
@@ -54,7 +59,10 @@ const comment = '/*\n' +
5459
'*/\n';
5560

5661
// Clean
57-
export const clean = () => del(['dist', 'build']);
62+
export const clean = () => del([dist, 'build']);
63+
64+
// Clean all
65+
export const cleanall = () => del([dist, 'build', 'wwwroot']);
5866

5967
// Styles
6068
export const styles = () => {
@@ -66,7 +74,7 @@ export const styles = () => {
6674
compatibility: 'ie8'
6775
})))
6876
.pipe(gulpif(!PRODUCTION, sourcemaps.write()))
69-
.pipe(dest('dist/css'))
77+
.pipe(dest(dist + '/assets/css'))
7078
.pipe(server.stream());
7179
};
7280

@@ -76,20 +84,20 @@ const addBanner = () => {
7684
.pipe(banner(comment, {
7785
pkg
7886
}))
79-
.pipe(dest('dist/php'));
87+
.pipe(dest(dist));
8088
};
8189

8290
// Images
8391
export const images = () => {
8492
return src('src/images/**/*.{jpg,jpeg,png,svg,gif}')
8593
.pipe(gulpif(PRODUCTION, imagemin()))
86-
.pipe(dest('dist/images'));
94+
.pipe(dest(dist + '/assets/images'));
8795
};
8896

8997
// Copy
9098
export const copy = () => {
9199
return src('src/**/*.{php,mo,po,htaccess}')
92-
.pipe(dest('dist'));
100+
.pipe(dest(dist));
93101
};
94102

95103
// Copy production htaccess
@@ -125,7 +133,7 @@ export const scripts = () => {
125133
jquery: 'jQuery'
126134
}
127135
}))
128-
.pipe(dest('dist/js'));
136+
.pipe(dest(dist + '/assets/js'));
129137
};
130138

131139
// Bump version x.x.1
@@ -236,6 +244,21 @@ export const addRelease = () => {
236244
return run(`git add CHANGELOG.md README.md package.json && git commit --amend --no-edit && git tag v${pkg.version} -m "Version ${pkg.version}" && git push && git push --tags`).exec();
237245
};
238246

247+
// Run vagrant up and install its dependencies to work with WordPress
248+
const setupEnvironment = () => {
249+
return run('vagrant up').exec();
250+
};
251+
252+
// Sets the configuration
253+
const setConfig = () => {
254+
return src('./wwwroot/wp-config.php')
255+
.pipe(replace('database_name_here', process.env.LOCAL_DB_NAME))
256+
.pipe(replace('username_here', process.env.LOCAL_DB_USER))
257+
.pipe(replace('password_here', process.env.LOCAL_DB_PASS))
258+
.pipe(dest('./wwwroot'));
259+
};
260+
261+
export const setup = series(setupEnvironment, setConfig);
239262
export const dev = series(clean, parallel(styles, images, copy, scripts), addBanner, serve, watchForChanges);
240263
export const build = series(clean, parallel(styles, images, copy, scripts), addBanner, copyHtaccessProduction, compress);
241264
export const bump = series(bumpPrompt);

‎vagrantsetup.sh

+1
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ tar -xzvf latest.tar.gz
3535
rm latest.tar.gz
3636
sudo rsync -av wordpress/* /var/www/html/
3737
rm -R wordpress
38+
rm /var/www/html/index.html
3839

3940
# Set permissions
4041
sudo chown -R www-data:www-data /var/www/html/

0 commit comments

Comments
 (0)
Please sign in to comment.