Skip to content
This repository has been archived by the owner on Sep 16, 2019. It is now read-only.

Update config process #1084

Merged
merged 6 commits into from
Sep 21, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
node_modules
npm-debug.log
dist
config.yml
*.sass-cache*
*.log
.idea/
*.swp

24 changes: 19 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,19 +28,23 @@ $ cd FoundationPress
$ npm install
```

### 2. Get started
### 2. Configuration

For WordPress development on localhost, I recommend using [MAMP](https://www.mamp.info/en/) for Mac, [WAMP](http://www.wampserver.com/en/download-wampserver-64bits/) for Windows or [LAMP](https://www.linux.com/learn/easy-lamp-server-installation) for Linux.
#### YAML config file
FoundationPress includes a `config-default.yml` file. To make changes to the configuration, make a copy of `config-default.yml` and name it `config.yml` and make changes to that file. The `config.yml` file is ignored by git so that each environment can use a different configuration with the same git repo.

If you want to take advantage of browser-sync (automatic browser refresh when a file is saved), simply open your gulpfile.babel.js and put your local dev-server address and port (e.g http://localhost:8888) in the `URL` variable.
At the start of the build process a check is done to see if a `config.yml` file exists. If `config.yml` exists, the configuration will be loaded from `config.yml`. If `config.yml` does not exist, `config-default.yml` will be used as a fallback.

Then, simply run
#### Browsersync setup
If you want to take advantage of [Browsersync](https://www.browsersync.io/) (automatic browser refresh when a file is saved), simply open your `config.yml` file after creating it in the previous step, and put your local dev-server address and port (e.g http://localhost:8888) in the `url` property under the `BROWSERSYNC` object.

### 3. Get started

```bash
$ npm start
```

### 3. Compile assets for production
### 4. Compile assets for production

When building for production, the CSS and JS will be minified. To minify the assets in your `/dist` folder, run

Expand Down Expand Up @@ -83,6 +87,16 @@ Foundation modules are loaded in the `src/assets/js/app.js` file. By default all
* [Clean FoundationPress install](http://foundationpress.olefredrik.com/)
* [FoundationPress Kitchen Sink - see every single element in action](http://foundationpress.olefredrik.com/kitchen-sink/)

## Local Development
We recommend using one of the following setups for local WordPress development:

* [MAMP](https://www.mamp.info/en/) (macOS)
* [WAMP](http://www.wampserver.com/en/download-wampserver-64bits/) (Windows)
* [LAMP](https://www.linux.com/learn/easy-lamp-server-installation) (Linux)
* [Local](https://local.getflywheel.com/) (macOS/Windows)
* [VVV (Varying Vagrant Vagrants)](https://github.com/Varying-Vagrant-Vagrants/VVV) (Vagrant Box)
* [Trellis](https://roots.io/trellis/)

## Resources

* [Foundation UI Kit for Adobe XD](https://gumroad.com/l/foundation-ui-kit-xd)
Expand Down
5 changes: 5 additions & 0 deletions config.yml → config-default.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# Browsersync config
BROWSERSYNC:
# URL of local development server goes here (ex. http://localsite.dev)
url: ""

# Autoprefixer will make sure your CSS works with these browsers
COMPATIBILITY:
- "last 2 versions"
Expand Down
45 changes: 35 additions & 10 deletions gulpfile.babel.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
'use strict';

import plugins from 'gulp-load-plugins';
import gutil from 'gulp-util';
import yargs from 'yargs';
import browser from 'browser-sync';
import gulp from 'gulp';
Expand All @@ -18,17 +19,43 @@ const $ = plugins();
const PRODUCTION = !!(yargs.argv.production);

// Load settings from settings.yml
const { COMPATIBILITY, PATHS } = loadConfig();
const { BROWSERSYNC, COMPATIBILITY, PATHS } = loadConfig();

// Check if file exists synchronously
function checkFileExists(filepath) {
let flag = true;
try {
fs.accessSync(filepath, fs.F_OK);
} catch(e) {
flag = false;
}
return flag;
}

// Load default or custom YML config file
function loadConfig() {
let ymlFile = fs.readFileSync('config.yml', 'utf8');
return yaml.load(ymlFile);
gutil.log('Loading config file...');

if (checkFileExists('config.yml')) {
// config.yml exists, load it
gutil.log(gutil.colors.cyan('config.yml'), 'exists, loading', gutil.colors.cyan('config.yml'));
let ymlFile = fs.readFileSync('config.yml', 'utf8');
return yaml.load(ymlFile);

} else if(checkFileExists('config-default.yml')) {
// config-default.yml exists, load it
gutil.log(gutil.colors.cyan('config.yml'), 'does not exist, loading', gutil.colors.cyan('config-default.yml'));
let ymlFile = fs.readFileSync('config-default.yml', 'utf8');
return yaml.load(ymlFile);

} else {
// Exit if config.yml & config-default.yml do not exist
gutil.log('Exiting process, no config file exists.');
gutil.log('Error Code:', err.code);
process.exit(1);
}
}

// Enter URL of your local server here
// Example: 'http://localhost:8888'
var URL = '';

// Build the "dist" folder by running all of the below tasks
gulp.task('build',
gulp.series(clean, sass, javascript, images, copy));
Expand Down Expand Up @@ -113,7 +140,7 @@ function images() {
// Start BrowserSync to preview the site in
function server(done) {
browser.init({
proxy: URL,
proxy: BROWSERSYNC.url,

ui: {
port: 8080
Expand All @@ -129,8 +156,6 @@ function reload(done) {
done();
}



// Watch for changes to static assets, pages, Sass, and JavaScript
function watch() {
gulp.watch(PATHS.assets, copy);
Expand Down
9 changes: 1 addition & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,10 @@
"homepage": "https://foundationpress.olefredrik.com",
"license": "MIT",
"main": "gulpfile.js",

"scripts": {
"start": "gulp",
"build": "gulp build --production"
},

"keywords": [
"FoundationPress",
"WordPress",
Expand All @@ -22,14 +20,12 @@
"customizable",
"responsive"
],

"dependencies": {
"foundation-sites": "6.4.1",
"jquery": "~3.0.0",
"what-input": "^4.1.3",
"motion-ui": "~1.2.2"
},

"devDependencies": {
"babel-core": "^6.24.1",
"babel-loader": "^6.4.1",
Expand All @@ -49,6 +45,7 @@
"gulp-sass": "^2.1.0",
"gulp-sourcemaps": "^1.6.0",
"gulp-uglify": "^1.2.0",
"gulp-util": "^3.0.8",
"js-yaml": "^3.4.6",
"panini": "^1.3.0",
"rimraf": "^2.4.3",
Expand All @@ -58,20 +55,16 @@
"webpack-stream": "^3.2.0",
"yargs": "^3.8.0"
},

"repository": {
"type": "git",
"url": "https://github.com/olefredrik/foundationpress.git"
},

"bugs": {
"url": "https://github.com/olefredrik/foundationpress/issues"
},

"babel": {
"presets": [
"es2015"
]
}

}