@@ -3,6 +3,7 @@ const glob = require('glob')
3
3
const argv = require ( 'yargs' ) . argv
4
4
const del = require ( 'del' )
5
5
const merge = require ( 'webpack-merge' ) . smart
6
+ const webpack = require ( 'webpack' )
6
7
let webpackConfig = { }
7
8
8
9
///////////////////
@@ -20,8 +21,6 @@ config.merge({
20
21
sass : true ,
21
22
html : true ,
22
23
} ,
23
- enableCssThemes : false ,
24
- // create additional .rtl.css
25
24
enableCssRTL : false ,
26
25
// expose globals
27
26
expose : [ ] ,
@@ -41,6 +40,8 @@ config.merge({
41
40
cssDest : 'dist/assets/css' ,
42
41
jsSrc : 'src/js/**/**.{js,vue}' ,
43
42
jsDest : 'dist/assets/js' ,
43
+ htmlSrc : 'src/html/pages/**/**.html' ,
44
+ htmlContext : './src/html/pages' ,
44
45
htmlSearchPaths : [
45
46
'./src/html'
46
47
] ,
@@ -73,6 +74,7 @@ catch (e) {
73
74
///////////////////////////////
74
75
75
76
mix . options ( config . get ( 'laravelMixOptions' ) )
77
+ mix . setPublicPath ( '.' )
76
78
77
79
/////////////
78
80
// Aliases //
@@ -157,9 +159,7 @@ if (__RUN === 'copy' || (!__RUN && config.get('runTasks:copy'))) {
157
159
// SASS //
158
160
//////////
159
161
160
- // npm run development -- --env.theme dark
161
- const __THEME = argv . env ? argv . env . theme || 'default' : 'default'
162
-
162
+ // npm run development -- --env.run sass
163
163
mix . extend ( 'addSassIncludePaths' , function ( webpackConfig ) {
164
164
const Vue = require ( 'laravel-mix/src/components/Vue' )
165
165
const vue = new Vue ( )
@@ -208,37 +208,19 @@ if (__RUN === 'sass' || (!__RUN && config.get('runTasks:sass'))) {
208
208
includePaths : [ 'node_modules' ]
209
209
}
210
210
211
- if ( config . get ( 'enableCssThemes' ) ) {
212
- // inject $theme variable
213
- sassOptions . data = '$theme: ' + __THEME + ';'
214
- __DIST_CSS += '/themes/' + __THEME
215
- }
216
-
217
211
for ( let file of glob . sync ( config . get ( 'sassSrc' ) , { ignore : '**/_*' } ) ) {
218
212
mix . sass ( file , __DIST_CSS , sassOptions )
219
213
}
220
214
215
+
221
216
/////////
222
217
// RTL //
223
218
/////////
224
219
225
220
if ( config . get ( 'enableCssRTL' ) ) {
226
- const WebpackRTLPlugin = require ( 'webpack-rtl-plugin' )
227
- const WebpackRTLWrapPlugin = require ( 'webpack-rtl-wrap-plugin' )
228
- const cacheDirectory = path . resolve ( path . join ( 'temp' , 'rtl' , __THEME ) )
229
-
230
- del . sync ( cacheDirectory )
231
-
232
- webpackConfig = merge ( webpackConfig , {
233
- plugins : [
234
- // Creates .rtl.css
235
- new WebpackRTLPlugin ( {
236
- minify : false
237
- } ) ,
238
- // wraps CSS into [dir=ltr|rtl]
239
- new WebpackRTLWrapPlugin ( {
240
- cacheDirectory
241
- } )
221
+ mix . options ( {
222
+ postCss : [
223
+ require ( 'postcss-rtl' )
242
224
]
243
225
} )
244
226
}
@@ -253,15 +235,15 @@ if (__RUN === 'html' || (!__RUN && config.get('runTasks:html'))) {
253
235
let Entry = require ( 'laravel-mix/src/builder/Entry' )
254
236
let entry = new Entry ( )
255
237
256
- for ( let file of glob . sync ( 'src/html/pages/*.html' , { ignore : '**/_*' } ) ) {
238
+ for ( let file of glob . sync ( config . get ( 'htmlSrc' ) , { ignore : '**/_*' } ) ) {
257
239
entry . add ( 'mix' , path . resolve ( file ) )
258
240
}
259
241
260
242
let loaders = [ {
261
243
loader : 'file-loader' ,
262
244
options : {
263
245
name : config . get ( 'htmlDest' ) ,
264
- context : './src/html/pages' ,
246
+ context : config . get ( 'htmlContext' ) ,
265
247
useRelativePath : false
266
248
}
267
249
} ]
@@ -331,6 +313,44 @@ if (Config.webpackConfig) {
331
313
webpackConfig = merge ( Config . webpackConfig , webpackConfig )
332
314
}
333
315
316
+ mix . webpackConfig ( {
317
+ plugins : [
318
+ new webpack . LoaderOptionsPlugin ( {
319
+ // test: /\.xxx$/, // may apply this only for some modules
320
+ options : {
321
+ jsBeautify : {
322
+ "html" : {
323
+ "allowed_file_extensions" : [ "html" , "xhtml" , "shtml" , "xml" , "svg" ] ,
324
+ "indent_size" : 4 ,
325
+ "indent_inner_html" : true ,
326
+ "wrap_attributes" : "force-aligned" ,
327
+ "max_preserve_newlines" : 1
328
+ }
329
+ }
330
+ }
331
+ } )
332
+ ] ,
333
+ resolve : {
334
+ symlinks : false ,
335
+ modules : [
336
+ path . resolve ( __dirname , '..' , 'node_modules' ) ,
337
+ 'node_modules'
338
+ ] ,
339
+ } ,
340
+ module : {
341
+ rules : [ {
342
+ test : / \. j s x ? $ / ,
343
+ exclude : / ( n o d e _ m o d u l e s \/ ( c o r e - j s | @ b a b e l \b ) | b o w e r _ c o m p o n e n t s ) / ,
344
+ use : [
345
+ {
346
+ loader : 'babel-loader' ,
347
+ options : Config . babel ( )
348
+ }
349
+ ]
350
+ } ]
351
+ }
352
+ } )
353
+
334
354
mix . webpackConfig ( webpackConfig )
335
355
336
356
/////////////////
0 commit comments