Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 6792228

Browse files
author
Alexey Litvinov
committed
moved hook to the template engine
and small update for styles
1 parent a06cd27 commit 6792228

File tree

5 files changed

+19
-17
lines changed

5 files changed

+19
-17
lines changed

‎demo/app/view-engine.js

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,19 @@
11
'use strict';
22

33
const babel = require('babel-core/register');
4-
const lodash = require('lodash');
4+
const forEach = require('lodash').forEach;
55
const React = require('react');
66
const ReactDOM = require('react-dom/server');
77

88
const doctype = '<!doctype html>';
99

10-
/**
11-
* @param {object} view
12-
*/
13-
function dropCache(view) {
14-
const detectView = new RegExp(`^${view}`);
15-
16-
lodash.forEach(require.cache, (view, identity) => {
17-
detectView.test(view.filename)
18-
&& delete require.cache[identity];
19-
});
20-
}
21-
2210
babel({
2311
only: /components/,
2412
});
2513

14+
// teaches node.js to load css files
15+
require('css-modules-require-hook/preset');
16+
2617
/**
2718
* @param {string} file
2819
* @param {object} opts
@@ -44,3 +35,15 @@ module.exports = function viewEngine(file, opts, cb) {
4435
dropCache(opts.settings.views);
4536
cb(null, markup);
4637
};
38+
39+
/**
40+
* @param {object} view
41+
*/
42+
function dropCache(view) {
43+
const detectView = new RegExp(`^${view}`);
44+
45+
forEach(require.cache, (view, identity) => {
46+
detectView.test(view.filename)
47+
&& delete require.cache[identity];
48+
});
49+
}

‎demo/app/worker.js

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,6 @@ const viewEngine = require('./view-engine');
77
const config = require('../package').config;
88
const app = express();
99

10-
// teaches node.js to load css files
11-
require('css-modules-require-hook/preset');
12-
1310
// sets react rendering engine
1411
app.engine('js', viewEngine);
1512
app.set('views', path.join(__dirname, '../components'));

‎demo/components/Button/Button.css

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
{
44
display: inline-block;
55

6+
margin: 0 0 20px;
67
padding: 0 11px;
78

89
cursor: pointer;

‎demo/components/Title/Title.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
.common
22
{
3-
margin: 20px0;
3+
margin: 0020px;
44

55
color: #333;
66

‎demo/webpack.config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ module.exports = {
3030
},
3131

3232
postcss: [
33+
// small sugar for CSS
3334
require('postcss-font-magician'),
3435
require('autoprefixer'),
3536
],

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /