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 | configureAssetPipeline: function() {},
|
88 | configureExpress: function() {},
|
89 |
|
90 | assets: {
|
91 | mincer: Mincer,
|
92 | root: root,
|
93 | production: env === 'production',
|
94 | mountPath: '/assets',
|
95 | manifestFile: path.resolve(root, 'public', 'assets', 'manifest.json'),
|
96 | paths: [],
|
97 | scanDirectories: [
|
98 | 'assets'
|
99 | ],
|
100 | },
|
101 |
|
102 | precompile: {
|
103 | target: path.resolve(root, 'public', 'assets'),
|
104 | images: true,
|
105 | fonts: true,
|
106 | files: [],
|
107 | options: {}
|
108 | },
|
109 |
|
110 | livereload: {
|
111 | active: env === 'development',
|
112 | ip: process.env.LIVERELOAD_IP || 'localhost',
|
113 | port: process.env.LIVERELOAD_PORT || 35729,
|
114 | script: function () {
|
115 | return util.format('//%s:%s/livereload.js', this.ip, this.port);
|
116 | },
|
117 | host: function() {
|
118 | return exports.host(this.ip, this.port);
|
119 | },
|
120 | watch: [],
|
121 | debug: env === 'development',
|
122 | exts: [
|
123 | 'js',
|
124 | 'coffee',
|
125 | 'json',
|
126 | 'html',
|
127 | 'jade',
|
128 | 'ejs',
|
129 | 'css',
|
130 | 'styl',
|
131 | 'less',
|
132 | 'png',
|
133 | 'gif',
|
134 | 'jpg',
|
135 | 'svg',
|
136 | 'ico',
|
137 | 'eof',
|
138 | 'ttf',
|
139 | 'woff',
|
140 | 'woff2'
|
141 | ]
|
142 | }
|
143 | };
|
144 | ```
|
145 |
|
146 |
|
147 | ## Mincer
|
148 |
|
149 | * [Mincer API Documentation](http://nodeca.github.io/mincer)
|
150 | * [Github Repo](https://github.com/nodeca/mincer)
|
151 |
|
152 | ## Connect Mincer
|
153 |
|
154 | * [Github Repo](https://github.com/clarkdave/connect-mincer)
|
155 |
|
156 | ## example font fix
|
157 |
|
158 | e.g. Font-Awesome
|
159 |
|
160 | ```Stylus
|
161 | //= require font-awesome/css/font-awesome.css
|
162 |
|
163 | @font-face {
|
164 | font-family: 'FontAwesome';
|
165 | src: url(asset_path('font-awesome/fonts/fontawesome-webfont.eot')+'?v=4.4.0');
|
166 | src: url(asset_path('font-awesome/fonts/fontawesome-webfont.eot')+'?#iefix&v=4.4.0') format('embedded-opentype'),
|
167 | url(asset_path('font-awesome/fonts/fontawesome-webfont.woff2')+'?v=4.4.0') format('woff2'),
|
168 | url(asset_path('font-awesome/fonts/fontawesome-webfont.woff')+'?v=4.4.0') format('woff'),
|
169 | url(asset_path('font-awesome/fonts/fontawesome-webfont.ttf')+'?v=4.4.0') format('truetype'),
|
170 | url(asset_path('font-awesome/fonts/fontawesome-webfont.svg')+'?v=4.4.0#fontawesomeregular') format('svg');
|
171 | font-weight: normal;
|
172 | font-style: normal;
|
173 | }
|
174 |
|
175 | body
|
176 | padding-top: 60px
|
177 | ```
|
178 |
|
179 | ## contributing
|
180 |
|
181 | * Found a bug? Create an issue!
|
182 | * Missing Feature? Create an issue or fork the repo, implement the feature and start an pull request.
|
183 |
|
184 | ## license
|
185 |
|
186 | [MIT](https://github.com/naxmefy/express-mincer-spa/blob/master/LICENSE) |
\ | No newline at end of file |