1 | # express-mincer-spa
|
2 |
|
3 | easy generator of frontend application with express backend and mincer
|
4 | supported asset pipeline.
|
5 |
|
6 | [![npm version](https://badge.fury.io/js/express-mincer-spa.svg)](https://badge.fury.io/js/express-mincer-spa)
|
7 | [![Dependency Status](https://gemnasium.com/naxmefy/express-mincer-spa.svg)](https://gemnasium.com/naxmefy/express-mincer-spa)
|
8 |
|
9 | [![Build Status](https://travis-ci.org/naxmefy/express-mincer-spa.svg?branch=master)](https://travis-ci.org/naxmefy/express-mincer-spa)
|
10 | [![Coverage Status](https://coveralls.io/repos/github/naxmefy/express-mincer-spa/badge.svg?branch=master)](https://coveralls.io/github/naxmefy/express-mincer-spa?branch=master)
|
11 |
|
12 |
|
13 | [![NPM](https://nodei.co/npm/express-mincer-spa.png?downloads=true&downloadRank=true&stars=true)](https://nodei.co/npm/express-mincer-spa/)
|
14 |
|
15 | ## installation
|
16 |
|
17 | ```
|
18 | $ npm install --global express-mincer-spa
|
19 | ```
|
20 |
|
21 | ## usage
|
22 |
|
23 | Generate new application
|
24 |
|
25 | ```
|
26 | $ ems new my-spa-application
|
27 | ```
|
28 |
|
29 | Start application
|
30 |
|
31 | ```
|
32 | $ ems start my-spa-application
|
33 |
|
34 | // or
|
35 |
|
36 | $ node my-spa-application
|
37 |
|
38 | // or
|
39 |
|
40 | $ cd my-spa-application
|
41 | $ node index.js
|
42 | ```
|
43 |
|
44 | Precompile assets
|
45 |
|
46 | ```
|
47 | $ ems precompile
|
48 | ```
|
49 |
|
50 | ## Main File
|
51 |
|
52 | ```JavaScript
|
53 | var expressMincerSpa = require('..');
|
54 | var app = module.exports = expressMincerSpa(__dirname, {
|
55 | precompile: {
|
56 | files: [
|
57 | // DEFINE HERE FILES U WANNA PRECOMPILE
|
58 | 'app.css',
|
59 | 'app.js'
|
60 | ]
|
61 | }
|
62 | });
|
63 |
|
64 | if(!module.parent) {
|
65 | app.start();
|
66 | }
|
67 | ```
|
68 |
|
69 | ## Default Options
|
70 |
|
71 | [see here in lib](https://github.com/naxmefy/express-mincer-spa/blob/master/lib/index.js#L117)
|
72 |
|
73 | ```JavaScript
|
74 | var defaultOpts = {
|
75 | port: process.env.PORT || 3000,
|
76 | ip: process.env.IP || '',
|
77 |
|
78 | host: function() {
|
79 | return exports.host(this.ip, this.port);
|
80 | },
|
81 |
|
82 | engine: 'jade',
|
83 | views: path.resolve(root, 'views'),
|
84 | public: path.resolve(root, 'public'),
|
85 | favicon: path.resolve(root, 'public', 'favicon.ico'),
|
86 |
|
87 | middlewareForStaticPublic: [],
|
88 | configureAssetPipeline: function(assetPipeline) {},
|
89 | configureExpress: function(app) {},
|
90 |
|
91 | assets: {
|
92 | mincer: Mincer,
|
93 | root: root,
|
94 | production: env === 'production',
|
95 | mountPath: '/assets',
|
96 | manifestFile: path.resolve(root, 'public', 'assets', 'manifest.json'),
|
97 | paths: [],
|
98 | scanDirectories: [
|
99 | 'assets'
|
100 | ],
|
101 | },
|
102 |
|
103 | precompile: {
|
104 | target: path.resolve(root, 'public', 'assets'),
|
105 | images: true,
|
106 | fonts: true,
|
107 | files: [],
|
108 | options: {}
|
109 | },
|
110 |
|
111 | livereload: {
|
112 | active: env === 'development',
|
113 | ip: process.env.LIVERELOAD_IP || 'localhost',
|
114 | port: process.env.LIVERELOAD_PORT || 35729,
|
115 | script: function () {
|
116 | return util.format('//%s:%s/livereload.js', this.ip, this.port);
|
117 | },
|
118 | host: function() {
|
119 | return exports.host(this.ip, this.port);
|
120 | },
|
121 | watch: [],
|
122 | debug: env === 'development',
|
123 | exts: [
|
124 | 'js',
|
125 | 'coffee',
|
126 | 'json',
|
127 | 'html',
|
128 | 'jade',
|
129 | 'ejs',
|
130 | 'css',
|
131 | 'styl',
|
132 | 'less',
|
133 | 'png',
|
134 | 'gif',
|
135 | 'jpg',
|
136 | 'svg',
|
137 | 'ico',
|
138 | 'eof',
|
139 | 'ttf',
|
140 | 'woff',
|
141 | 'woff2'
|
142 | ]
|
143 | }
|
144 | };
|
145 | ```
|
146 |
|
147 |
|
148 | ## Mincer
|
149 |
|
150 | * [Mincer API Documentation](http://nodeca.github.io/mincer)
|
151 | * [Github Repo](https://github.com/nodeca/mincer)
|
152 |
|
153 | ## Connect Mincer
|
154 |
|
155 | * [Github Repo](https://github.com/clarkdave/connect-mincer)
|
156 |
|
157 | ## example font fix
|
158 |
|
159 | e.g. Font-Awesome
|
160 |
|
161 | ```Stylus
|
162 | //= require font-awesome/css/font-awesome.css
|
163 |
|
164 | @font-face {
|
165 | font-family: 'FontAwesome';
|
166 | src: url(asset_path('font-awesome/fonts/fontawesome-webfont.eot')+'?v=4.4.0');
|
167 | src: url(asset_path('font-awesome/fonts/fontawesome-webfont.eot')+'?#iefix&v=4.4.0') format('embedded-opentype'),
|
168 | url(asset_path('font-awesome/fonts/fontawesome-webfont.woff2')+'?v=4.4.0') format('woff2'),
|
169 | url(asset_path('font-awesome/fonts/fontawesome-webfont.woff')+'?v=4.4.0') format('woff'),
|
170 | url(asset_path('font-awesome/fonts/fontawesome-webfont.ttf')+'?v=4.4.0') format('truetype'),
|
171 | url(asset_path('font-awesome/fonts/fontawesome-webfont.svg')+'?v=4.4.0#fontawesomeregular') format('svg');
|
172 | font-weight: normal;
|
173 | font-style: normal;
|
174 | }
|
175 |
|
176 | body
|
177 | padding-top: 60px
|
178 | ```
|
179 |
|
180 | ## contributing
|
181 |
|
182 | * Found a bug? Create an issue!
|
183 | * Missing Feature? Create an issue or fork the repo, implement the feature and start an pull request.
|
184 |
|
185 | ## license
|
186 |
|
187 | [MIT](https://github.com/naxmefy/express-mincer-spa/blob/master/LICENSE)
|