Commit 6c0add61 by Иван Кубота

add global scss injections

parent 873ee75d
...@@ -99,18 +99,25 @@ var transformServe = function(dir) { ...@@ -99,18 +99,25 @@ var transformServe = function(dir) {
if( err ){ if( err ){
next(); next();
}else{ }else{
console.log(req.url)
if(pack && pack.scss && pack.scss.shared){
data = pack.scss.shared+';\n'+data;
}
sass.render( { sass.render( {
data: data,
file: path.join( __dirname, dir, req.url ), file: path.join( __dirname, dir, req.url ),
sourceMap: true, sourceMap: true,
importer: function( url, prev, done ){ importer: function( url, prev, done ){
setTimeout( function( result ){ setTimeout( function( result ){
var name = path.resolve( path.dirname( prev ), url ); if(url[0] === '/'){
url = path.join( __dirname, dir, url.substr(1));
}
var displayName = path.relative( path.join( __dirname, dir ), path.resolve( path.dirname( prev ), url ) ) var displayName = path.relative( path.join( __dirname, dir ), path.resolve( path.dirname( prev ), url ) )
var name = path.resolve( path.dirname( prev ), url );
// TODO Add errors
done( { done( {
file: displayName, // only one of them is required, see section Special Behaviours. file: displayName, // only one of them is required, see section Special Behaviours.
contents: fs.readFileSync( name ) + '' contents: fs.readFileSync( name ) + ''
} ); } );
}, 10 ); }, 10 );
} }
......
...@@ -2,4 +2,7 @@ module.exports = { ...@@ -2,4 +2,7 @@ module.exports = {
src: './src', src: './src',
entry: {js: 'main.jsx', html: 'index.html'}, entry: {js: 'main.jsx', html: 'index.html'},
public: './public', public: './public',
scss: {
shared: `@import '/base.scss';`
}
}; };
\ No newline at end of file
...@@ -6,3 +6,5 @@ $l-green: #34BE5B; ...@@ -6,3 +6,5 @@ $l-green: #34BE5B;
$gray: #a6a6a6; $gray: #a6a6a6;
$font: 'SF Pro Text', Arial, sans-serif; $font: 'SF Pro Text', Arial, sans-serif;
b {color: pink}
\ No newline at end of file
@import '../../../base.scss';
.page-header { .page-header {
position: fixed; position: fixed;
top: 0; top: 0;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment