js-kompo-utils 1.0.4 → 1.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import path from 'path';
|
|
2
|
+
import tailwindcss from 'tailwindcss';
|
|
3
|
+
import webpack from 'webpack';
|
|
4
|
+
|
|
5
|
+
export const defaultSassOptions = {
|
|
6
|
+
sassOptions: {
|
|
7
|
+
quietDeps: true,
|
|
8
|
+
api: 'modern-compiler',
|
|
9
|
+
silenceDeprecations: ["legacy-js-api"],
|
|
10
|
+
}
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
export const buildDefaultWebpackMix = (mix, options = {}) => {
|
|
14
|
+
const appPath = options.appPath || process.cwd();
|
|
15
|
+
const tailwindConfig = options.tailwindConfig || './tailwind.config.js';
|
|
16
|
+
|
|
17
|
+
mix.js('resources/js/app.js', 'public/js').vue()
|
|
18
|
+
.sass('resources/scss/app.scss', 'public/css', defaultSassOptions)
|
|
19
|
+
.options({
|
|
20
|
+
processCssUrls: false,
|
|
21
|
+
legacyNodePolyfills: false,
|
|
22
|
+
postCss: [ tailwindcss(tailwindConfig) ],
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
mix.version();
|
|
26
|
+
|
|
27
|
+
mix.webpackConfig({
|
|
28
|
+
resolve: {
|
|
29
|
+
modules: [path.resolve(appPath, 'node_modules'), 'node_modules'],
|
|
30
|
+
alias: {
|
|
31
|
+
// Ensure vue resolves from consuming app (not symlinked package)
|
|
32
|
+
'vue/dist/vue': path.resolve(appPath, 'node_modules/vue/dist/vue.js'),
|
|
33
|
+
'vue$': path.resolve(appPath, 'node_modules/vue/dist/vue.js'),
|
|
34
|
+
},
|
|
35
|
+
},
|
|
36
|
+
module: {
|
|
37
|
+
rules: [{
|
|
38
|
+
test: /\.js$/,
|
|
39
|
+
include: /js-kompo-utils/,
|
|
40
|
+
type: 'javascript/auto',
|
|
41
|
+
}]
|
|
42
|
+
},
|
|
43
|
+
plugins: [
|
|
44
|
+
new webpack.ProvidePlugin({
|
|
45
|
+
$: 'jquery',
|
|
46
|
+
jQuery: 'jquery',
|
|
47
|
+
'window.jQuery': 'jquery',
|
|
48
|
+
'Vue': 'vue/dist/vue'
|
|
49
|
+
}),
|
|
50
|
+
],
|
|
51
|
+
optimization: {
|
|
52
|
+
splitChunks: {
|
|
53
|
+
chunks: 'all',
|
|
54
|
+
cacheGroups: {
|
|
55
|
+
default: false,
|
|
56
|
+
vendors: false,
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
// Allow vue-loader to process .vue files from js-kompo-utils
|
|
63
|
+
mix.override((config) => {
|
|
64
|
+
config.module.rules.forEach((rule) => {
|
|
65
|
+
if (rule.test && rule.test.toString().includes('vue') && rule.exclude) {
|
|
66
|
+
rule.exclude = /node_modules\/(?!js-kompo-utils)/;
|
|
67
|
+
}
|
|
68
|
+
});
|
|
69
|
+
});
|
|
70
|
+
};
|
|
@@ -11,6 +11,8 @@ export class KompoJsConfigBuilder {
|
|
|
11
11
|
windowDecorators = [];
|
|
12
12
|
windowUtilsObject = {};
|
|
13
13
|
appSelector = '#app';
|
|
14
|
+
includeBroadcasting = false;
|
|
15
|
+
echoBroadcasterConfig = null;
|
|
14
16
|
|
|
15
17
|
beforeStepCallbacks = {};
|
|
16
18
|
afterStepCallbacks = {};
|
|
@@ -136,6 +138,25 @@ export class KompoJsConfigBuilder {
|
|
|
136
138
|
return this;
|
|
137
139
|
}
|
|
138
140
|
|
|
141
|
+
withBroadcasting(config) {
|
|
142
|
+
this.includeBroadcasting = true;
|
|
143
|
+
this.echoBroadcasterConfig = {
|
|
144
|
+
broadcaster: 'pusher',
|
|
145
|
+
key: process.env.MIX_PUSHER_APP_KEY,
|
|
146
|
+
cluster: process.env.MIX_PUSHER_APP_CLUSTER,
|
|
147
|
+
forceTLS: true,
|
|
148
|
+
...config
|
|
149
|
+
};
|
|
150
|
+
|
|
151
|
+
return this;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
withoutBroadcasting() {
|
|
155
|
+
this.includeBroadcasting = false;
|
|
156
|
+
this.echoBroadcasterConfig = null;
|
|
157
|
+
return this;
|
|
158
|
+
}
|
|
159
|
+
|
|
139
160
|
/**
|
|
140
161
|
* @param {object} plugin - A Vue plugin to register via Vue.use()
|
|
141
162
|
* @returns {KompoJsConfigBuilder}
|
|
@@ -218,6 +239,8 @@ export class KompoJsInitializer {
|
|
|
218
239
|
|
|
219
240
|
this._callStep('bootTutorialEngineIfRequired');
|
|
220
241
|
|
|
242
|
+
this._callStep('bootBroadcastingIfRequired');
|
|
243
|
+
|
|
221
244
|
this._callStep('instanceApp');
|
|
222
245
|
}
|
|
223
246
|
|
|
@@ -325,6 +348,15 @@ export class KompoJsInitializer {
|
|
|
325
348
|
}
|
|
326
349
|
}
|
|
327
350
|
|
|
351
|
+
bootBroadcastingIfRequired() {
|
|
352
|
+
if (this.config.includeBroadcasting) {
|
|
353
|
+
const Echo = require("laravel-echo");
|
|
354
|
+
this.window.Pusher = require('pusher-js'); // We usually use pusher, but if user want can set another way
|
|
355
|
+
|
|
356
|
+
this.window.Echo = new Echo(this.config.echoBroadcasterConfig);
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
|
|
328
360
|
instanceApp() {
|
|
329
361
|
new this.window.Vue({
|
|
330
362
|
el: this.config.appSelector,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "js-kompo-utils",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.6",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "app.js",
|
|
6
6
|
"scripts": {
|
|
@@ -18,8 +18,21 @@
|
|
|
18
18
|
"highlight.js": "^11.11.1",
|
|
19
19
|
"jquery": "^3.6.0",
|
|
20
20
|
"kompo-googlemaps": "^1.0.14",
|
|
21
|
+
"laravel-echo": "^2.3.1",
|
|
21
22
|
"libphonenumber-js": "^1.12.40",
|
|
23
|
+
"pusher-js": "^8.4.3",
|
|
22
24
|
"typed.js": "^3.0.0",
|
|
25
|
+
"vue": "^2.7.16",
|
|
23
26
|
"vue-qrcode-reader": "^3.1.0"
|
|
27
|
+
},
|
|
28
|
+
"devDependencies": {
|
|
29
|
+
"autoprefixer": "^10.4.7",
|
|
30
|
+
"axios": "^0.21",
|
|
31
|
+
"laravel-mix": "^6.0.49",
|
|
32
|
+
"lodash": "^4.17.19",
|
|
33
|
+
"postcss": "^8.4.14",
|
|
34
|
+
"sass": "^1.83.0",
|
|
35
|
+
"tailwindcss": "^3.1.6",
|
|
36
|
+
"vue-kompo": "^3.1.1"
|
|
24
37
|
}
|
|
25
38
|
}
|