-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.mix.js
98 lines (84 loc) · 3.5 KB
/
webpack.mix.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
const mix = require('laravel-mix')
const exec = require('child_process').exec
require('dotenv').config()
/*
|--------------------------------------------------------------------------
| Mix Asset Management
|--------------------------------------------------------------------------
|
| Mix provides a clean, fluent API for defining some Webpack build steps
| for your Laravel application. By default, we are compiling the Sass
| file for the application as well as bundling up all the JS files.
|
*/
const glob = require('glob')
const path = require('path')
/*
|--------------------------------------------------------------------------
| Vendor assets
|--------------------------------------------------------------------------
*/
function mixAssetsDir(query, cb) {
;(glob.sync('resources/' + query) || []).forEach(f => {
f = f.replace(/[\\\/]+/g, '/')
cb(f, f.replace('resources', 'public'))
})
}
const sassOptions = {
precision: 5,
includePaths: ['node_modules', 'resources/assets/']
}
// plugins Core stylesheets
mixAssetsDir('sass/base/plugins/**/!(_)*.scss', (src, dest) =>
mix.sass(src, dest.replace(/(\\|\/)sass(\\|\/)/, '$1css$2').replace(/\.scss$/, '.css'), {sassOptions})
)
// pages Core stylesheets
mixAssetsDir('sass/base/pages/**/!(_)*.scss', (src, dest) =>
mix.sass(src, dest.replace(/(\\|\/)sass(\\|\/)/, '$1css$2').replace(/\.scss$/, '.css'), {sassOptions})
)
// Core stylesheets
mixAssetsDir('sass/base/core/**/!(_)*.scss', (src, dest) =>
mix.sass(src, dest.replace(/(\\|\/)sass(\\|\/)/, '$1css$2').replace(/\.scss$/, '.css'), {sassOptions})
)
// script js
mixAssetsDir('js/scripts/**/*.js', (src, dest) => mix.scripts(src, dest))
/*
|--------------------------------------------------------------------------
| Application assets
|--------------------------------------------------------------------------
*/
mixAssetsDir('vendors/js/**/*.js', (src, dest) => mix.scripts(src, dest))
mixAssetsDir('vendors/css/**/*.css', (src, dest) => mix.copy(src, dest))
mixAssetsDir('vendors/**/**/images', (src, dest) => mix.copy(src, dest))
mixAssetsDir('vendors/css/editors/quill/fonts/', (src, dest) => mix.copy(src, dest))
mixAssetsDir('fonts', (src, dest) => mix.copy(src, dest))
mixAssetsDir('fonts/**/**/*.css', (src, dest) => mix.copy(src, dest))
mix.copyDirectory('resources/images', 'public/images')
mix.copyDirectory('resources/data', 'public/data')
mix
.js('resources/js/core/app-menu.js', 'public/js/core')
.js('resources/js/core/app.js', 'public/js/core')
.sass('resources/sass/core.scss', 'public/css', {sassOptions})
.sass('resources/sass/overrides.scss', 'public/css', {sassOptions})
.sass('resources/sass/base/custom-rtl.scss', 'public/css', {sassOptions})
.sass('resources/assets/scss/style-rtl.scss', 'public/css', {sassOptions})
.sass('resources/assets/scss/style.scss', 'public/css', {sassOptions})
mix.then(() => {
if (process.env.MIX_CONTENT_DIRECTION === 'rtl') {
let command = `node ${path.resolve('node_modules/rtlcss/bin/rtlcss.js')} -d -e ".css" ./public/css/ ./public/css/`
exec(command, function(err, stdout, stderr) {
if (err !== null) {
console.log(err)
}
})
}
})
// if (mix.inProduction()) {
// mix.version()
// mix.webpackConfig({
// output: {
// publicPath: '/demo/vuexy-bootstrap-laravel-admin-template-new/demo-2/'
// }
// })
// mix.setResourceRoot('/demo/vuexy-bootstrap-laravel-admin-template-new/demo-2/')
// }