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