Skip to content
This repository was archived by the owner on Oct 6, 2025. It is now read-only.

Commit 48593b2

Browse files
authored
Merge pull request #29 from vasilyz/exclude-files-option
Include and Exclude files option
2 parents 99ccee6 + 4c1a9ae commit 48593b2

File tree

3 files changed

+13
-3
lines changed

3 files changed

+13
-3
lines changed

php-loader.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,14 @@ const phpLoader = {
2525
nodir: true
2626
}).filter((file) => {
2727
return path.extname(file.path) === '.php';
28+
}).filter((file) => {
29+
if (typeof options.includeOnly === 'undefined') return true;
30+
var filename = path.basename(file.path, '.php');
31+
return options.includeOnly.includes(filename);
32+
}).filter((file) => {
33+
if (typeof options.exclude === 'undefined') return true;
34+
var filename = path.basename(file.path, '.php');
35+
return !options.exclude.includes(filename);
2836
}).forEach((file) => {
2937
var filename = file.path.split(langDirectory + path.sep)[1];
3038
var filename = filename.replace('\\', '/');

php.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ module.exports = function (indexContent) {
1010
let loaderPath = 'node_modules' + path.sep + '@kirschbaum-development' + path.sep + 'laravel-translations-loader' + path.sep + 'php.js';
1111

1212
try {
13-
options = loaderUtils.parseQuery(this.query);
13+
options = loaderUtils.getOptions(this);
1414
} catch (e) { }
1515

1616
if (path.dirname(this.resource).includes(path.dirname(loaderPath))) {

readme.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -177,10 +177,12 @@ mix.translations();
177177
mix.extend('translations', new class {
178178
webpackRules() {
179179
return {
180-
test: path.resolve(__dirname, '../resources/lang/index.js'),
180+
test: path.resolve(__dirname, './resources/lang/index.js'),
181181
loader: '@kirschbaum-development/laravel-translations-loader/php',
182182
options: {
183-
parameters: "$1"
183+
parameters: "$1",
184+
includeOnly: ['auth', 'validation'],
185+
exclude: [],
184186
}
185187
}
186188
}

0 commit comments

Comments
 (0)