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
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Most of the projects I work on have a very similar structure. This repo was mainly for me, so I didn't have to recreate everything from scratch for all projects. Now it's turned into a repo for anyone needed a quick starting place for new projects. The idea behind these files is to be modified and molded into whatever environment you are working in. Let me break down a couple of key areas for you.
3
+
Most of the projects I work on have a very similar structure. And this repo was mainly for me, so I didn't have to recreate everything from scratch for every project. Now it's turned into a repo for anyone needed a quick starting place for new projects. This is meant to be a good starting place and meant to be modifiable to fit your needs.
4
4
5
5
## Project Overview
6
6
@@ -9,4 +9,175 @@ This starter pack gets you with everything you need to get up and running quickl
9
9
10
10
## Project Structure
11
11
12
-
All of your source files live in the `src` directory. You have three main folders in here, `images` | `scripts` | `styles`.
12
+
All of your source files live in the `src` directory. You have three main folders in here, `images` | `scripts` | `styles`.
13
+
14
+
The basic folder structure is as follows :
15
+
```
16
+
root-folder/
17
+
├── build/
18
+
├── src/
19
+
│ ├── images/
20
+
│ ├── scripts/
21
+
│ ├── styles/
22
+
│ └── index.html
23
+
│
24
+
├── gulp-config.js
25
+
├── gulp-env.js
26
+
├── gulpfile.js
27
+
└── package.json
28
+
```
29
+
30
+
All of your work will be done with in the `src` folder, and everything will be compiled to the `build` folder.
31
+
32
+
## Gulp Tasks
33
+
34
+
You have three main tasks that you will use most often.
35
+
36
+
`gulp __start-local__`
37
+
38
+
`gulp __compile-assets__`
39
+
40
+
`gulp __lint-everything__`
41
+
42
+
43
+
### Start Local
44
+
45
+
Start local is your main development command. This triggers a series of tasks that takes care of everything. Let's break it down.
46
+
47
+
#### Clean Build
48
+
49
+
`gulp clean:build`
50
+
51
+
This tasks simply cleans the build folder.
52
+
53
+
#### Compile Styles
54
+
55
+
`gulp task:compile-styles`
56
+
57
+
Compile styles takes your Sass `.scss` and `.sass` files, converts to `.css`, adds all the vendor prefixes specified in the config, writes the source maps, places the output in the build folder, and injects the changes in the browser.
58
+
59
+
#### Compile Scripts
60
+
61
+
`gulp task:compile-scripts`
62
+
63
+
Compile scripts takes your `.js` files, allows you to write in ES6+ and compile down to least common environment based on the config settings, moves the files the build folder, and refreshes the browser.
64
+
65
+
This does basic conversion. It does not handle tree shaking, or module imports, or other advanced stuff. There will be another project coming that handles that portion of it.
66
+
67
+
#### Compile HTML
68
+
69
+
`gulp task:compile-html`
70
+
71
+
Currently, this is a simple file mover. It checks if any markup has change, if it has, move it and reload the browser.
72
+
73
+
#### Compile Images
74
+
75
+
`gulp task:compile-html`
76
+
77
+
Currently, this is another simple file mover. Moves all the images to the build folder.
78
+
79
+
#### Start Watch
80
+
81
+
`gulp task:start-watch`
82
+
83
+
Dependent on `gulp task:start-server`. This task listens to all the files for changes, if any file changes run the appropriate task and reload the browser.
84
+
85
+
#### Start Server
86
+
87
+
`gulp task:start-server`
88
+
89
+
Based on your environment path, this task either spins up a local server or triggers a local host already defined, spins up your default browser.
90
+
91
+
### Compile Assets
92
+
93
+
Compile assets runs all the same tasks, sans the server. This task is meant for production server to run.
94
+
95
+
### Lint Everything
96
+
97
+
It's important to have everything conforming to the coding style agreed upon with your team. If you don't know where to start, this is good place. Check out the `gulp-config.js` file for the linting rules for JavaScript and CSS. Most of the configurable items are set with a value that I like to code against. Try it out and if you find those rules are to lax or strict for you, change them how you best see fit.
98
+
99
+
#### Lint Styles
100
+
101
+
`gulp _lint-styles`
102
+
103
+
This is a group task that calls two other tasks. `clean:sass` and `lint:sass`.
104
+
105
+
#### Clean Sass
106
+
107
+
`gulp clean:sass`
108
+
109
+
Formatting everything manually is cool and all, but it's even better to have a tool to auto format for you.
110
+
111
+
#### Lint Sass
112
+
113
+
`gulp lint:sass`
114
+
115
+
After things have been formatted properly, check if your code conforms with the code style you have put in place.
116
+
117
+
#### Lint Scripts
118
+
119
+
`gulp _lint-scripts`
120
+
121
+
This is a group task that calls two other tasks. `clean:js` and `lint:js`.
122
+
123
+
#### Clean JS
124
+
125
+
`gulp clean:js`
126
+
127
+
Formatting everything manually is cool and all, but it's even better to have a tool to auto format for you.
128
+
129
+
#### Lint JS
130
+
131
+
`gulp lint:js`
132
+
133
+
After things have been formatted properly, check if your code conforms with the code style you have put in place.
134
+
135
+
---
136
+
## Environment file
137
+
138
+
`gulp-env.js`
139
+
140
+
This environment file should be the only file you need to touch from project to project. Mainly the `siteInstanceName` and `srcPath` / `buildPath`. These variables dictate how the system builds. If you are utilizing this in a project that is not as cut and dry as a `./src` and a `./build` folder, then change the start and end locations here.
141
+
142
+
The `siteInstanceName` is for a local host environment. If you are using a localhost such as MAMP or IIS, then `siteInstanceName` should reflect the url those systems have set up. If you are not using a local host situation, then leave `siteInstanceName` as `./` and Browser Sync will take care of the rest.
143
+
144
+
145
+
---
146
+
147
+
## Gulp Config
148
+
149
+
This file should be touched a little less frequently than the environment file, but may need to better reflect the structure of your system.
150
+
151
+
Each file type has their own structure with three items. `source` | `lintPath` | `build` Take a look at what these are currently set to and update according to your system.
152
+
153
+
If there is not a file represented in a group that needs to be, simply update the file extension where appropriate separate with a comma. NO SPACES.
154
+
155
+
For example, you need to support `.twig` file extension, update the `html.source` like so. `${env.srcPath}/**/*.{html,htm,php,cshtml,twig}`
156
+
157
+
158
+
### Options
159
+
160
+
These are the options that power the variables that affect how the files come out in the end.
161
+
162
+
163
+
#### Auto Prefixer
164
+
165
+
By default it has set been set up to support `last 4 versions` or `> 9%` browser usage.
166
+
167
+
#### Babel Env Options
168
+
169
+
Similar to Auto Prefixer, Babel can be set up to compile down to browsers last n versions.
170
+
171
+
If you are looking to play with a feature that is being proposed, then you need to install the babel plugin and include it in the `plugins` section for babel options.
172
+
173
+
#### Formatting
174
+
175
+
These options are based on how I like to work and have found pretty common to how teams work. This should be reviewed and agreed upon by your team, or what works with your style if working solo.
176
+
177
+
#### Linting JavaScript
178
+
179
+
These options are ones I have tweaked based my likings. Try these out, tweak as you see fit.
180
+
181
+
#### Linting Styles
182
+
183
+
These options are ones I have tweaked based my likings. Try these out, tweak as you see fit.
0 commit comments