Skip to content
This repository was archived by the owner on Nov 20, 2020. It is now read-only.

Commit 0c25fe9

Browse files
authored
Merge pull request #67 from akester/master
Add support for include paths config option for node-sass
2 parents 266fb97 + 71e8429 commit 0c25fe9

File tree

4 files changed

+29
-4
lines changed

4 files changed

+29
-4
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -479,6 +479,8 @@ webpack:
479479
sass:
480480
filename: '[name].css'
481481
all_chunks: true
482+
include_paths:
483+
- [include dirs for node-sass]
482484
```
483485

484486
### URL

src/Component/Configuration/CodeBlock.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
* output : {
3535
* << output >>
3636
* }
37+
* << root >>
3738
* };
3839
*
3940
* @author Harold Iedema <[email protected]>
@@ -48,11 +49,12 @@ class CodeBlock
4849
PRE_LOADER = 'pre_loader',
4950
LOADER = 'loader',
5051
POST_LOADER = 'post_loader',
51-
OUTPUT = 'output';
52+
OUTPUT = 'output',
53+
ROOT = 'root';
5254

5355
// Available types to allow easy validation
5456
private $types = [
55-
'entry', 'header', 'resolve', 'resolve_loader', 'plugin', 'pre_loader', 'loader', 'post_loader', 'output'
57+
'entry', 'header', 'resolve', 'resolve_loader', 'plugin', 'pre_loader', 'loader', 'post_loader', 'output', 'root'
5658
];
5759

5860
// Chunks collection

src/Component/Configuration/ConfigGenerator.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,12 @@ public function getConfiguration()
8080
$code[] = $tab2 . $this->getChunks(CodeBlock::POST_LOADER, ',' . PHP_EOL . $tab2, ',' . PHP_EOL . $tab2);
8181
$code[] = $tab1 . ']';
8282
$code[] = '}';
83-
$code[] = '';
83+
if (!empty($this->getChunks(CodeBlock::ROOT))) {
84+
$code[] = ',';
85+
$code[] = $tab1 . $this->getChunks(CodeBlock::ROOT, ',' . PHP_EOL . $tab1, ',' . PHP_EOL . $tab1);
86+
} else {
87+
$code[] = '';
88+
}
8489
$code[] = '};';
8590
$code[] = '';
8691

src/Component/Configuration/Loader/SassLoader.php

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@ public static function applyConfiguration(NodeBuilder $node_builder)
3030
->children()
3131
->booleanNode('all_chunks')->defaultTrue()->end()
3232
->scalarNode('filename')->defaultNull()->end()
33+
->arrayNode('include_paths')
34+
->defaultValue(array())
35+
->prototype('scalar')->end()
3336
->end()
3437
->end();
3538
}
@@ -43,9 +46,22 @@ public function getCodeBlocks()
4346
return [new CodeBlock()];
4447
}
4548

49+
$block = new CodeBlock;
50+
$single = false;
51+
52+
if (!empty($config['include_paths'])) {
53+
$block->set(CodeBlock::ROOT, 'sassLoader: { includePaths: [\'' . implode('\',\'', $config['include_paths']) . '\']}');
54+
$single = true;
55+
}
56+
4657
if (empty($config['filename'])) {
4758
// If the filename is not set, apply inline style tags.
48-
return [(new CodeBlock())->set(CodeBlock::LOADER, '{ test: /\.scss$/, loader: \'style!css!sass\' }')];
59+
$block->set(CodeBlock::LOADER, '{ test: /\.scss$/, loader: \'style!css!sass\' }');
60+
$single = true;
61+
}
62+
63+
if ($single) {
64+
return [$block];
4965
}
5066

5167
// If a filename is set, apply the ExtractTextPlugin

0 commit comments

Comments
 (0)