This repository has been archived by the owner on Jun 6, 2024. It is now read-only.
forked from MartNijland/bpv-website-craft
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.mix.js
86 lines (76 loc) · 2.48 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
const mix = require('laravel-mix');
require('dotenv').config();
const browserSyncProxy = process.env.MIX_BROWSERSYNC_PROXY === undefined ? 'http://localhost:1422/' : process.env.MIX_BROWSERSYNC_PROXY;
const useHTTPS = process.env.MIX_HTTPS === 'enabled';
// ============================================================= //
// Browsersync settings for both regular and HTTPS
// ============================================================= //
const browserSyncConfigGeneral = {
injectChanges: false,
notify: false,
files: ['web/assets/css/{*,**/*}.css', 'web/assets/js/{*,**/*}.js', 'templates/{*,**/*}.twig']
}
const browserSyncConfig = {
...browserSyncConfigGeneral,
proxy: browserSyncProxy,
port: 1423,
https: false,
open: 'local',
};
const browserSyncConfigHTTPS = {
...browserSyncConfigGeneral,
host: process.env.MIX_HTTPS_HOST,
proxy: browserSyncProxy,
https: {
key: process.env.MIX_HTTPS_PATH_KEY,
cert: process.env.MIX_HTTPS_PATH_CERT,
},
open: 'external'
};
// ============================================================= //
// Main mix setup
// ============================================================= //
mix.setPublicPath(path.normalize('./web'))
.js('src/js/app.js', 'assets/js')
.sass('src/scss/app.scss', 'assets/css')
// Configure typescript
.webpackConfig({
module: {
rules: [
{
test: /\.tsx?$/,
loader: "ts-loader",
exclude: /node_modules/
}
]
},
resolve: {
modules: [
"node_modules",
path.resolve(__dirname, 'src/ts')
],
alias: {
"@": path.resolve(__dirname, 'src/ts/'),
},
extensions: ["*", ".js", ".jsx", ".vue", ".ts", ".tsx"]
}
})
// Copy folders
.copy('src/favicon', 'web/assets/favicon')
.copy('src/fonts', 'web/assets/fonts')
.copy('src/icons', 'web/assets/icons')
.copy('src/img', 'web/assets/img')
.copy('src/logos', 'web/assets/logos')
.copy('src/videos', 'web/assets/videos')
// Add browsersync here
.browserSync(useHTTPS ? browserSyncConfigHTTPS : browserSyncConfig)
.version();
// Run a dev server if we run the serve command
if (process.env.SERVE === "true") {
const Connect = require('gulp-connect-php');
Connect.server({
base: './web',
port: 1422,
keepalive: true
});
}