1 | # Asset-Mate
|
2 | Asset-Mate auto-generates a gulpfile based on a manifest, which enables you to easily compile, rewrite, copy, or deploy Javascript, ES6, SCSS, CSS and images
|
3 |
|
4 | ###How it works
|
5 | 1) You fill in a manifest of your source-tree assets, and desired destinations
|
6 |
|
7 | 2) It auto-generates a gulp file
|
8 |
|
9 | 3) Call 'watch', or 'build' with gulp to have it make your output assets
|
10 |
|
11 | 4) Call 'deploy' with gulp to have it deployed to an AWS S3 bucket
|
12 |
|
13 | ###What it can do
|
14 | - Compile ES6 files
|
15 | - Compile SASS files
|
16 | - Minify ES6 or Javascript files
|
17 | - Autoprefix CSS files (automatic cross-browser support)
|
18 | - Do find and replace (rewrites) on all text files
|
19 | - Create multiple output sizes of images
|
20 | - Simple copying of files
|
21 | - Deploy to an S3 bucket
|
22 | - Keeps an internal list of files (so that you don't copy everything every time)
|
23 |
|
24 | ###Requirements
|
25 | - Node and NPM
|
26 | - Ffmpeg (If you want to resize images)
|
27 |
|
28 | ###Installation
|
29 | 1) npm install -g asset-mate
|
30 |
|
31 | 2) cd to the root of your project directory
|
32 |
|
33 | 3) asset-mate new
|
34 |
|
35 | ###Commands
|
36 | - asset-mate new
|
37 | - asset-mate autogenerate
|
38 | - asset-mate clearcache
|
39 | - gulp (build | deploy | watch)
|
40 | - gulp (build | deploy | watch) [--src 0] [ --dest 0]
|
41 | - gulp (build | deploy | watch) [--src src_name] [ --dest dest_name]
|
42 |
|
43 | ###Usage
|
44 | When you call 'asset-mate new' it installs gulp and the dependencies you need to run the gulp file, and adds a 'gulp-manifest.json' file to the root of your project.
|
45 |
|
46 | 'gulp-manifest.json' will start with an example structure that you can fill in with the details of your own project. You can have multiple sources and multiple destinations, and it understands arrayed and glob format descriptions of your files.
|
47 | Once you've finished describing your manifest, call 'asset-mate autogenerate'. This will build your gulp file for you. Then use the commands 'gulp build' or 'gulp watch' to have it produce your assets.
|
48 |
|
49 | If you specify 's3Bucket' and 'awsCredentialsProfile' in a destination in your manifest, calling 'gulp deploy' will use that information to automatically upload your files to the given S3 bucket. You can also specify an 's3Prefix' if you would like the files in that destination prefixed in the bucket.
|
50 |
|
51 | ###Example
|
52 | A common example case is when you have a source directory that you would like compiled into three formats:
|
53 |
|
54 | - A local 'dev' folder in which sources are not minified
|
55 | - A local 'dist' folder in which sources are minified
|
56 | - A 'deploy' folder in which sources are both minified and any urls in those files point to S3 or CDN addresses
|
57 |
|
58 | Your gulp-manifest.json file for this use case might look as follows:
|
59 |
|
60 | ```
|
61 | [
|
62 | {
|
63 | "name" : "my-app",
|
64 | "src" : {
|
65 | "directory" : "src",
|
66 | "es6" : "js/*.js",
|
67 | "js" : "other_file/js/*.js",
|
68 | "scss" : "scss/*.scss",
|
69 | "css" : "css/*",
|
70 | "images" : [
|
71 | {
|
72 | "glob" : "images/**",
|
73 | "sizes" : {
|
74 | "big" : "100%",
|
75 | "med" : 0.5
|
76 | }
|
77 | }
|
78 | ],
|
79 | "copy" : "**",
|
80 | "copyExclude" : ["folder_to_exclude1/*", "folder_to_exclude2/*"]
|
81 | },
|
82 | "dest" : [
|
83 | {
|
84 | "name" : "dev",
|
85 | "directory" : "dist_dev",
|
86 | "minify" : false,
|
87 | "autoprefix" : true,
|
88 | "rewrites" : { "ASSET_URL" : "dist_dev" },
|
89 | },
|
90 | {
|
91 | "name" : "dist",
|
92 | "directory" : "dist",
|
93 | "minify" : true,
|
94 | "autoprefix" : true,
|
95 | "rewrites" : { "ASSET_URL" : "" },
|
96 | },
|
97 | {
|
98 | "name" : "deploy",
|
99 | "directory" : "deploy",
|
100 | "minify" : true,
|
101 | "autoprefix" : true,
|
102 | "rewrites" : { "ASSET_URL" : "aws-cdn.com" },
|
103 | "s3Bucket" : "my-bucket",
|
104 | "s3Prefix" : "app-asset",
|
105 | "awsCredentialsProfile" : "default"
|
106 | }
|
107 | ]
|
108 | }
|
109 | ]
|
110 | ```
|
111 |
|
112 | You can omit any of the keys that are not relevant to your project and it should still build ok.
|
113 |
|
114 | (Note: I've also used this example to demonstrate that the images list will understand you specifying your sizes as both percentages and fractions)
|
115 |
|
116 | Since I've specified the copy glob as "**", when gulp runs it will copy and rewrite all files in the 'src' directory that don't match with those specified in the other globs, it will parse everything in the es6 glob using Babel and Browserify, it will resize my images and appended them with their size name (e.g. image_med.png), and it will compile and autoprefix any css.
|
117 |
|
118 | The results will vary as per the rules specified in each of the destinations
|
119 |
|
120 | When I call 'gulp deploy' it will ignore the first two destinations (as they don't list any s3 information) any only deploy the files in the third.
|
121 |
|
122 | If I only want to watch or build to a single destination, the second for example, I can call 'gulp build --src my-app --dest dist' or 'gulp build --src 0 --dest 1'
|
123 |
|
124 | Also, any subsequent times I run the build command it 'should' check the source files against their destinations and an internal record and only copy those with changes (this might be a bit flakey though)
|
125 |
|
126 | Oh and! Subsequent deploys should also upload only the files that have changed
|
127 |
|