Skip to content

Commit 987aa03

Browse files
author
Visnu Pitiyanuvath
committed
use assetmanager for css too
1 parent a0f3d90 commit 987aa03

File tree

6 files changed

+533
-36
lines changed

6 files changed

+533
-36
lines changed

.gitignore

-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
.DS_Store
22
.idea
33
.monitor
4-
*.css
54
node_modules
65
tmp/*
76
config/secrets.coffee

.nodemonignore

-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
# https://github.com/remy/nodemon
22

33
.git/*
4-
/public/stylesheets/*
54
/views/*
65
/designs/*
76
/LICENSE

config/app.js

+28-28
Original file line numberDiff line numberDiff line change
@@ -39,37 +39,24 @@ app.db = require('../models')(env.mongo_url);
3939
// config
4040
app.configure(function() {
4141
var coffee = require('coffee-script')
42-
, uglify_jsp = require("uglify-js").parser
43-
, uglify_pro = require("uglify-js").uglify
4442
, stylus = require('stylus');
4543

46-
app.use(stylus.middleware({
47-
src: app.paths.public,
48-
dest: app.paths.public,
49-
compile: function(str, path) {
50-
return stylus(str)
51-
.set('compress', true)
52-
.set('filename', path)
53-
.set('paths', [ __dirname, app.paths.public ]);
54-
}
55-
}));
56-
5744
var assetManager = require('connect-assetmanager')({
5845
js: {
5946
route: /\/javascripts\/all-[a-z0-9]+\.js/,
6047
path: __dirname + '/../public/javascripts/',
6148
dataType: 'javascript',
62-
debug: true,
49+
debug: env.node_env === 'development',
6350
preManipulate: {
6451
'^': [
65-
function(file, path, index, isLast, callback) {
66-
callback(file.replace(/#socketIoPort#/g, env.port));
52+
function(src, path, index, isLast, callback) {
53+
callback(src.replace(/#socketIoPort#/g, env.port));
6754
}
68-
, function(file, path, index, isLast, callback) {
55+
, function(src, path, index, isLast, callback) {
6956
if (/\.coffee$/.test(path)) {
70-
callback(coffee.compile(file));
57+
callback(coffee.compile(src));
7158
} else {
72-
callback(file);
59+
callback(src);
7360
}
7461
}
7562
]
@@ -91,20 +78,33 @@ app.configure(function() {
9178
'application.coffee',
9279
'*'
9380
]
94-
, 'postManipulate': {
81+
},
82+
css: {
83+
route: /\/stylesheets\/all-[a-z0-9]+\.css/,
84+
path: __dirname + '/../public/stylesheets/',
85+
dataType: 'css',
86+
debug: env.node_env === 'development',
87+
preManipulate: {
9588
'^': [
96-
function(file, path, index, isLast, callback) {
97-
if (env.production) {
98-
var ast = uglify_jsp.parse(file);
99-
ast = uglify_pro.ast_mangle(ast);
100-
ast = uglify_pro.ast_squeeze(ast);
101-
callback(uglify_pro.gen_code(ast, { beautify: true, indent_level: 0 }));
89+
function(src, path, index, isLast, callback) {
90+
if (/\.styl$/.test(path)) {
91+
stylus(src)
92+
.set('compress', false)
93+
.set('filename', path)
94+
.set('paths', [ __dirname, app.paths.public ])
95+
.render(function(err, css) {
96+
callback(err || css);
97+
});
10298
} else {
103-
callback(file);
99+
callback(src);
104100
}
105101
}
106102
]
107-
}
103+
},
104+
files: [ // order matters here
105+
'vendor/normalize.css',
106+
'application.styl'
107+
]
108108
}
109109
});
110110
app.use(assetManager);

public/stylesheets/application.styl

-5
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,6 @@ red = hsl(0, 60%, 60%)
4545
font-style normal
4646
font-size medium
4747

48-
header, footer, nav, aside, section
49-
display block
5048
time
5149
display inline
5250

@@ -80,9 +78,6 @@ a:link, a:visited
8078
.scary
8179
color red
8280

83-
a img
84-
border 0
85-
8681
button, input[type=submit], a.button
8782
font-family 'Droid Sans', 'Helvetica Neue', Helvetica, Arial, sans-serif
8883
font-size large

0 commit comments

Comments
 (0)