forked from laravel/laravel
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
194 lines (152 loc) · 5.92 KB
/
gulpfile.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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
const gulp = require('gulp'),
elixir = require('laravel-elixir'),
babel = require('gulp-babel'),
rename = require("gulp-rename"), //use to save file with dest
argv = require('yargs').argv; // use to get arguments
require('laravel-elixir-vue-2');
elixir.config.sourcemaps = false;
// Shortcut name for common paths
var assetsDir = elixir.config.assetsPath; // resources/assets
var bowerDir = assetsDir + '/bower/'; // resources/assets/bower/
var foundationDir = bowerDir + 'foundation-sites/'; // resources/assets/bower/foundation-sites/
var publicDir = elixir.config.publicPath + '/'; // public/
var publicCssDir = publicDir + '/css/'; // public/css/
var publicJsDir = publicDir + '/js/'; // public/js/
// ===== MAIN ==================================================================
elixir(function(mix) {
doCommon(mix); // Assets required in both master and admin pages
doFrontEnd(mix); // Assets required only in the master page
doBackend(mix); // Assets required only in the admin page
//doVueComponents(mix); // Vue components
});
/*
Transform ES2016
Ej: yo have a index_es.js write in ES2016 at resources/views/admin/users
you must run ./node_modules/.bin/gulp compile -d admin/users -f index
and it genarate resources/views/admin/users/index.js write in standar javascript
*/
gulp.task('compile', function() {
var directory = 'resources/views/'+argv.d;
var filename = argv.f;
gulp.src(directory+'/'+filename+'_es.js')
.pipe(babel({
presets: ['es2016']
}))
.pipe(rename(filename+'.js'))
.pipe(gulp.dest(directory))
});
// ===== COMMON ================================================================
function doCommon(mix)
{
// Foundation app.js
mix.copy(assetsDir + '/js/app.js', foundationDir + 'js/');
// Foundation datepicker
mix.copy(bowerDir + 'foundation-datepicker/css/foundation-datepicker.min.css', publicCssDir + 'datepicker.css');
mix.copy(bowerDir + 'foundation-datepicker/js/foundation-datepicker.min.js', publicJsDir + 'datepicker.js');
// Responsive tables
mix.copy(bowerDir + 'responsive-tables/responsive-tables.css', publicCssDir + 'responsive-tables.css');
mix.copy(bowerDir + 'responsive-tables/responsive-tables.js', publicJsDir + 'responsive-tables.js');
// Offcanvas extras
mix.styles('css/offcanvas.css', publicCssDir + 'offcanvas.css', assetsDir);
mix.scripts('js/offcanvas.js', publicJsDir + 'offcanvas.js', assetsDir);
// Markdown preview in full screen
mix.scripts(['marked/marked.min.js', 'screenfull/dist/screenfull.js'], publicJsDir + 'markdown.js', bowerDir);
// Data-tables for log viewer
mix.styles(['jquery.dataTables.min.css', 'dataTables.foundation.min.css'], publicCssDir + 'datatables.css', bowerDir + 'datatables/media/css/');
mix.scripts(['jquery.dataTables.min.js', 'dataTables.foundation.js'], publicJsDir + 'datatables.js', bowerDir + 'datatables/media/js/');
}
// ===== FRONTEND ==============================================================
function doFrontEnd(mix)
{
// Foundation components to include
var components = [
// Components
"js/foundation.core.js",
"js/foundation.util.keyboard.js",
"js/foundation.dropdown.js",
"js/foundation.util.motion.js",
"js/foundation.util.box.js",
"js/foundation.util.triggers.js",
"js/foundation.util.mediaQuery.js",
"js/foundation.util.nest.js",
"js/foundation.offcanvas.js",
"js/foundation.dropdownMenu.js",
];
// Build CSS
mix.sass('master.scss', publicCssDir + 'master.css', null, { includePaths: [foundationDir + 'scss/', bowerDir + 'spinners/stylesheets']});
// Build JavaScript
mix.webpack(components, publicJsDir + 'master.js', foundationDir);
components = [
// Vendor dependencies
'../modernizr/modernizr.js',
'../jquery/dist/jquery.js',
'../fastclick/lib/fastclick.js',
'../what-input/what-input.js',
//master.js
'../../../../public/js/master.js',
'js/app.js'
];
mix.scripts(components, publicJsDir + 'master.js', foundationDir);
}
// ===== BACKEND ===============================================================
function doBackend(mix)
{
// Foundation components to include
var components = [
// Components
"js/foundation.core.js",
"js/foundation.util.motion.js",
"js/foundation.util.keyboard.js",
"js/foundation.dropdown.js",
"js/foundation.util.box.js",
"js/foundation.util.triggers.js",
"js/foundation.util.mediaQuery.js",
"js/foundation.util.nest.js",
"js/foundation.toggler.js",
"js/foundation.reveal.js",
"js/foundation.accordionMenu.js",
"js/foundation.drilldown.js",
"js/foundation.util.timerAndImageLoader.js",
"js/foundation.util.touch.js",
"js/foundation.offcanvas.js",
"js/foundation.dropdownMenu.js",
"js/foundation.magellan.js",
"js/foundation.toggler.js",
"js/foundation.tabs.js",
"js/foundation.slider.js",
"js/foundation.responsiveMenu.js",
"js/foundation.responsiveToggle.js",
"js/foundation.sticky.js",
];
// Build CSS
mix.sass('admin.scss', publicCssDir + 'admin.css', null, {includePaths: [foundationDir + 'scss/', bowerDir + 'spinners/stylesheets', bowerDir + 'motion-ui']});
// Build JavaScript
mix.webpack(components, publicJsDir + 'admin.js', foundationDir);
components = [
// Vendor dependencies
'../modernizr/modernizr.js',
'../jquery/dist/jquery.js',
'../fastclick/lib/fastclick.js',
'../what-input/what-input.js',
//admin.js
'../../../../public/js/admin.js',
'js/app.js',
//modal.js
'../../../../public/js/modal.js'
];
mix.scripts(components, publicJsDir + 'admin.js', foundationDir);
}
// ===== VUE ===============================================================
function doVueComponents(mix)
{
var config = elixir.webpack.mergeConfig({
entry: {
welcome: './resources/assets/js/pages/welcom.js',
//blog: './resources/assets/js/pages/blog.js'
},
output: {
filename: '[name].js' // Template based on keys in entry above
}
});
mix.webpack('components.js', null, null, null, config);
}