Skip to content

Commit d49ef9d

Browse files
committed
.vueignore support
1 parent adb930b commit d49ef9d

File tree

6 files changed

+76
-5
lines changed

6 files changed

+76
-5
lines changed

.meteor/versions

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ akryum:vue@1.0.3
44
akryum:vue-apollo@0.0.6
55
akryum:vue-app@0.0.1
66
akryum:vue-coffee@0.0.2
7-
akryum:vue-component@0.5.4
7+
akryum:vue-component@0.6.1
88
akryum:vue-component-dev-client@0.0.6
99
akryum:vue-component-dev-server@0.0.1
1010
akryum:vue-i18n@0.0.3

packages/vue-component/CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
# Changelog
22

3+
## 0.6.1 - 2016/07/08
4+
5+
- The `.vueignore` file inside a folder will only apply to that folder, similar to `.gitignore` files.
6+
7+
## 0.6.0 - 2016/07/08
8+
9+
- The compiler now parses `.vueignores` files that contains regexes for each line. The `.vue` files matching theses regexes will be ignored by the compiler.
10+
311
## 0.5.4 - 2016/07/07
412

513
- Fixed [Issue #41](https://github.com/Akryum/meteor-vue-component/issues/41).

packages/vue-component/README.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,16 @@ let packageName = this.$options.packageName;
132132

133133
It will be null if the components is in your application code.
134134

135+
### Ignore files
136+
137+
You can create `.vueignore` files with a RegEx on each line to exclude `.vue` files from the compilation based on their path. If the `.vueignore` is inside a folder, it only applies to that folder.
138+
139+
For example, you can add the following `.vueignore` file to your app inorder to ignore `.vue` files in the `node_modules` folders:
140+
141+
```
142+
node_modules/
143+
```
144+
135145
---
136146

137147
## Next steps

packages/vue-component/package.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Package.describe({
22
name: 'akryum:vue-component',
3-
version: '0.5.4',
3+
version: '0.6.1',
44
summary: 'VueJS single-file components that hot-reloads',
55
git: 'https://github.com/Akryum/meteor-vue-component',
66
documentation: 'README.md'

packages/vue-component/plugin/plugin.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
Plugin.registerCompiler({
22
extensions: ['vue'],
3-
archMatching: 'web'
3+
filenames: [IGNORE_FILE],
4+
archMatching: 'web',
45
}, () => new VueComponentCompiler());
56

67

packages/vue-component/plugin/vue-compiler.js

Lines changed: 54 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ import Future from 'fibers/future';
44
import async from 'async';
55
import { Meteor } from 'meteor/meteor';
66

7+
IGNORE_FILE = '.vueignore';
8+
79
global._vue_cache = global._vue_cache || {};
810

911
VueComponentCompiler = class VueComponentCompiler extends CachingCompiler {
@@ -19,6 +21,8 @@ VueComponentCompiler = class VueComponentCompiler extends CachingCompiler {
1921
processFilesForTarget(inputFiles) {
2022
const cacheMisses = [];
2123

24+
this.updateIgnoredConfig(inputFiles);
25+
2226
//console.log(`Found ${inputFiles.length} files.`);
2327

2428
const future = new Future;
@@ -70,8 +74,42 @@ VueComponentCompiler = class VueComponentCompiler extends CachingCompiler {
7074
}
7175
}
7276

77+
updateIgnoredConfig(inputFiles) {
78+
this.ignoreRules = [];
79+
for(let inputFile of inputFiles) {
80+
if(inputFile.getBasename() === IGNORE_FILE) {
81+
const contents = normalizeCarriageReturns(inputFile.getContentsAsString());
82+
const lines = contents.split('\n');
83+
let dirname = getFullDirname(inputFile);
84+
console.log(`dirname:'${dirname}'`);
85+
if(dirname === '.') {
86+
dirname = '';
87+
}
88+
for(let line of lines) {
89+
console.log(`line:'${line}'`);
90+
if(line !== '') {
91+
this.ignoreRules.push({
92+
dirname,
93+
reg: new RegExp(line),
94+
});
95+
}
96+
}
97+
}
98+
}
99+
}
100+
73101
isIgnored(inputFile) {
74-
return /node_modules/.test(inputFile.getPathInPackage())
102+
if(inputFile.getBasename() === IGNORE_FILE) {
103+
return true;
104+
}
105+
106+
for(let rule of this.ignoreRules) {
107+
const dirname = getFullDirname(inputFile);
108+
if(dirname.indexOf(rule.dirname) === 0 && rule.reg.test(inputFile.getPathInPackage())) {
109+
return true;
110+
}
111+
}
112+
return false;
75113
}
76114

77115
getCacheKey(inputFile) {
@@ -333,7 +371,7 @@ VueComponentCompiler = class VueComponentCompiler extends CachingCompiler {
333371
}
334372

335373
addStylesheet(inputFile, options) {
336-
const data = options.data.replace(rnReg, "\n").replace(rReg, "\n");
374+
const data = normalizeCarriageReturns(options.data);
337375
inputFile.addStylesheet({
338376
path: inputFile.getPathInPackage() + '.css',
339377
sourcePath: inputFile.getPathInPackage(),
@@ -343,6 +381,20 @@ VueComponentCompiler = class VueComponentCompiler extends CachingCompiler {
343381
}
344382
}
345383

384+
function normalizeCarriageReturns(contents) {
385+
return contents.replace(rnReg, "\n").replace(rReg, "\n");
386+
}
387+
388+
function getFullDirname(inputFile) {
389+
const packageName = inputFile.getPackageName();
390+
return (packageName? packageName + '/' : '') + inputFile.getDirname();
391+
}
392+
393+
function getFullPathInApp(inputFile) {
394+
const packageName = inputFile.getPackageName();
395+
return (packageName? packageName + '/' : '') + inputFile.getPathInPackage();
396+
}
397+
346398
const rnReg = new RegExp("\r\n", "g");
347399
const rReg = new RegExp("\r", "g");
348400
const globalFileNameReg = /\.global\.vue$/;

0 commit comments

Comments
 (0)