This repository has been archived by the owner on May 25, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathindex.js
56 lines (46 loc) · 1.5 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
'use strict';
const gulpUtil = require('gulp-util');
const fs = require('fs');
const InlineEnviromentVariablesPlugin = require('inline-environment-variables-webpack-plugin');
let config = {
silent: false,
path: './.env'
};
module.exports = {
config: function (options = {}) {
config = Object.assign(config, options);
this.execute();
},
execute: function () {
if(Elixir) {
try {
if (fs.existsSync(config.path)) {
console.log('found ' + config.path);
const webpack = require('laravel-elixir-webpack-official');
let envEntries = require('dotenv').config(config);
Elixir.webpack.mergeConfig({
plugins: [
new InlineEnviromentVariablesPlugin(envEntries)
]
});
}
else{
console.log(config.path + ' not found');
}
}
catch (e) {
new gulpUtil.PluginError({
plugin: 'laravel-elixir-env',
message: 'Currently only webpack is supported.'
});
}
}
else {
new gulpUtil.PluginError({
plugin: 'laravel-elixir-env',
message: 'Please include laravel-elixir-env after Laravel Elixir.'
});
}
}
};
module.exports.load = module.exports.execute();