forked from Jobcore-Talent/JC-Landing-Page
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.mix.js
169 lines (158 loc) · 6.76 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
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
const paths = require('./paths'),
mix = require('laravel-mix'),
copyWatched = require('laravel-mix-copy-watched'),
njk = require('laravel-mix-nunjucks'),
RemovePlugin = require('remove-files-webpack-plugin'),
MinifyHtmlWebpackPlugin = require('minify-html-webpack-plugin');
mix
// Laravel Mix options
.options({
clearConsole: false,
processCssUrls: false,
cssNano: {
svgo: false
}
})
.disableSuccessNotifications()
// BrowserSync init
.browserSync({
host: 'localhost',
port: 3000,
proxy: false,
server: {
baseDir: paths.base.dir,
serveStaticOptions: {
extensions: ['html']
}
},
files: [
'**/*.njk',
'**/*.html',
'**/*.js',
'**/*.css'
]
})
// Render Nunjucks templates
.njk(paths.src.templates, (mix.inProduction() ? paths.dist.base : paths.temp.base), {
data: {
...(require('./data.json')),
environment: mix.inProduction() ? 'production' : 'development'
},
envOptions: {
lstripBlocks: true,
autoescape: true,
trimBlocks: true
}
})
// Render Nunjucks templates for Documentation
.njk(paths.src.docs, (mix.inProduction() ? paths.dist.docs : paths.temp.docs), {
data: {
...(require('./data.json')),
environment: mix.inProduction() ? 'production' : 'development'
},
envOptions: {
lstripBlocks: true,
autoescape: true,
trimBlocks: true
}
})
// Delete all target directory
.webpackConfig({
plugins: [
new RemovePlugin({
before: {
include: [
mix.inProduction() ? paths.dist.base : paths.temp.base
]
}
})
]
});
if (mix.inProduction()) {
// Production mode
mix
// Copy plugins
.copyDirectory(paths.base.node + '/swiper', paths.dist.vendor + '/swiper')
.copyDirectory(paths.base.node + '/photoswipe', paths.dist.vendor + '/photoswipe')
.copyDirectory(paths.base.node + '/smooth-scroll', paths.dist.vendor + '/smooth-scroll')
.copyDirectory(paths.base.node + '/typed.js', paths.dist.vendor + '/typed.js')
.copyDirectory(paths.base.node + '/cookieconsent', paths.dist.vendor + '/cookieconsent')
.copyDirectory(paths.base.node + '/sticky-js', paths.dist.vendor + '/sticky-js')
.copyDirectory(paths.base.node + '/countup.js', paths.dist.vendor + '/countup.js')
.copyDirectory(paths.base.node + '/jarallax', paths.dist.vendor + '/jarallax')
.copyDirectory(paths.base.node + '/imagesloaded', paths.dist.vendor + '/imagesloaded')
.copyDirectory(paths.base.node + '/isotope-layout', paths.dist.vendor + '/isotope-layout')
// Compile JS file
.babel(paths.src.js + '/theme.js', paths.dist.js + '/theme.min.js')
// Concat, compile and minify JS core files
.babel([
paths.base.node + '/bluebird/js/browser/bluebird.min.js',
paths.base.node + '/aos/dist/aos.js',
paths.base.node + '/whatwg-fetch/dist/fetch.umd.js',
paths.base.node + '/string-includes-polyfill/string-includes-polyfill.js',
paths.base.node + '/number.isnan/isnan.js',
paths.base.node + '/fetch-inject/dist/fetch-inject.js',
paths.base.node + '/jquery/dist/jquery.min.js',
paths.base.node + '/bootstrap/dist/js/bootstrap.bundle.min.js'
], paths.dist.js + '/theme.core.min.js')
// Concat, compile and minify CSS files
.sass(paths.src.scss + '/theme.scss', paths.dist.css + '/theme.min.css')
// Copy images
.copyDirectory(paths.src.images, paths.dist.images)
// Minify HTML files
.webpackConfig({
plugins: [
new MinifyHtmlWebpackPlugin({
afterBuild: true,
src: paths.dist.base,
dest: paths.dist.base,
ignoreFileNameRegex: /assets/,
rules: {
collapseBooleanAttributes: true,
collapseWhitespace: true,
removeAttributeQuotes: true,
removeComments: true
}
})
]
})
// For documentation
.sass(paths.src.scss + '/docs.scss', paths.dist.docs + "/assets/css/docs.min.css");
} else {
// Development and default mode
mix
// Copy plugins
.copyDirectory(paths.base.node + '/swiper', paths.temp.vendor + '/swiper')
.copyDirectory(paths.base.node + '/photoswipe', paths.temp.vendor + '/photoswipe')
.copyDirectory(paths.base.node + '/smooth-scroll', paths.temp.vendor + '/smooth-scroll')
.copyDirectory(paths.base.node + '/typed.js', paths.temp.vendor + '/typed.js')
.copyDirectory(paths.base.node + '/cookieconsent', paths.temp.vendor + '/cookieconsent')
.copyDirectory(paths.base.node + '/sticky-js', paths.temp.vendor + '/sticky-js')
.copyDirectory(paths.base.node + '/countup.js', paths.temp.vendor + '/countup.js')
.copyDirectory(paths.base.node + '/jarallax', paths.temp.vendor + '/jarallax')
.copyDirectory(paths.base.node + '/imagesloaded', paths.temp.vendor + '/imagesloaded')
.copyDirectory(paths.base.node + '/isotope-layout', paths.temp.vendor + '/isotope-layout')
// Compile JS file
.babel(paths.src.js + '/theme.js', paths.temp.js + '/theme.js')
// Concat and compile JS core files
.babel([
paths.base.node + '/bluebird/js/browser/bluebird.min.js',
paths.base.node + '/aos/dist/aos.js',
paths.base.node + '/whatwg-fetch/dist/fetch.umd.js',
paths.base.node + '/string-includes-polyfill/string-includes-polyfill.js',
paths.base.node + '/number.isnan/isnan.js',
paths.base.node + '/fetch-inject/dist/fetch-inject.js',
paths.base.node + '/jquery/dist/jquery.min.js',
paths.base.node + '/bootstrap/dist/js/bootstrap.bundle.min.js'
], paths.temp.js + '/theme.core.js')
// Concat and compile CSS files
.sass(paths.src.scss + '/theme.scss', paths.temp.css + '/theme.css')
// Watch and copy images
.copyWatched(paths.src.images + '/**/*', paths.temp.images, {base: 'src/images'})
// Generate sourcemap file
.webpackConfig({
devtool: 'source-map'
})
// For documentation
.sass(paths.src.scss + '/docs.scss', paths.temp.docs + "/assets/css/docs.css");
}