Skip to content

Commit 53817b3

Browse files
committed
Merge branch 'dev'
2 parents a80d82c + 6905acf commit 53817b3

File tree

4 files changed

+39
-47
lines changed

4 files changed

+39
-47
lines changed

CoCreate.config.dev.js

Lines changed: 0 additions & 23 deletions
This file was deleted.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@
9999
"@cocreate/message-client": "^1.6.0",
100100
"@cocreate/modal": "^1.13.0",
101101
"@cocreate/observer": "^1.11.0",
102+
"@cocreate/openai": "^1.0.1",
102103
"@cocreate/organizations": "^1.18.0",
103104
"@cocreate/parallax": "^1.6.0",
104105
"@cocreate/pass": "^1.15.0",

src/components.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ lazyLoad('toolbar', '[toolbar-selector]', () => import(/*webpackChunkName: "tool
6666
lazyLoad('vdom', '[vdom-selector], [vdom-id]', () => import(/*webpackChunkName: "vdom-chunk"*/ '@cocreate/vdom'));
6767

6868
// Plugins
69-
// lazyLoad('charts', '[chart="chartjs"]', ()=> import (/*webpackChunkName: "charts-chunk"*/ '@cocreate/charts'));
69+
// lazyLoad('charts', '[chart="chartjs"]', ()=> import(/*webpackChunkName: "charts-chunk"*/ '@cocreate/charts'));
7070
// lazyLoad('domain', '[domain]', ()=> import (/*webpackChunkName: "domain-chunk"*/ '@cocreate/domain'));
7171
// lazyLoad('facebook', '[facebook]', ()=> import (/*webpackChunkName: "facebook-chunk"*/ '@cocreate/facebook'));
7272
// lazyLoad('fullcalendar', '.cal-container', ()=> import (/*webpackChunkName: "fullcalendar-chunk"*/ '@cocreate/fullcalendar'));
@@ -75,6 +75,7 @@ lazyLoad('vdom', '[vdom-selector], [vdom-id]', () => import(/*webpackChunkName:
7575
// lazyLoad('instagram', '[instagram]', ()=> import (/*webpackChunkName: "instagram-chunk"*/ '@cocreate/instagram'));
7676
// lazyLoad('lighthouse', '[lighthouse]', ()=> import (/*webpackChunkName: "lighthouse-chunk"*/ '@cocreate/lighthouse'));
7777
// lazyLoad('linkedin', '[linkedin]', ()=> import (/*webpackChunkName: "linkedin-chunk"*/ '@cocreate/linkedin'));
78+
lazyLoad('openai', '[openai]', () => import(/*webpackChunkName: "openai-chunk"*/ '@cocreate/openai'));
7879
lazyLoad('pickr', '.color-picker', () => import(/*webpackChunkName: "pickr-chunk"*/ '@cocreate/pickr'));
7980
// lazyLoad('pinterest', '[pinterest]', ()=> import (/*webpackChunkName: "pinterest-chunk"*/ '@cocreate/pinterest'));
8081
// lazyLoad('plaid', '[plaid]', ()=> import (/*webpackChunkName: "plaid-chunk"*/ '@cocreate/plaid'));

webpack.config.js

Lines changed: 36 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,15 @@
1-
// Webpack uses this to work with directories
21
const fs = require('fs');
32
const path = require('path');
4-
const util = require('util');
3+
const upload = require('@cocreate/cli/src/commands/upload.js')
54

65
const { CleanWebpackPlugin } = require('clean-webpack-plugin');
76
const TerserPlugin = require("terser-webpack-plugin");
87
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
98
const CssMinimizerPlugin = require('css-minimizer-webpack-plugin');
109

11-
12-
// const getLogger = require('webpack-log');
13-
// const log = getLogger({ name: 'webpack-batman' });
14-
// log.info(__filename);
15-
// let version = require('./package.json').version;
16-
// log.info(version);
1710
module.exports = async (env, argv) => {
18-
let isProduction = false
19-
if (argv.mode === 'production')
20-
isProduction = true
11+
const isProduction = argv.mode === 'production'
12+
const isWatch = argv.watch === true;
2113

2214
const config = {
2315
// Path to your entry point. From this file Webpack will begin his work
@@ -40,8 +32,6 @@ module.exports = async (env, argv) => {
4032
plugins: [
4133
new CleanWebpackPlugin(),
4234
new MiniCssExtractPlugin({
43-
// Options similar to the same options in webpackOptions.output
44-
4535
filename: isProduction ? '[name].min.css' : '[name].css',
4636
// chunkFilename: isProduction ? '[name].min.css' : '[name].css',
4737
chunkFilename: (path) => {
@@ -54,7 +44,7 @@ module.exports = async (env, argv) => {
5444
],
5545

5646
devServer: {
57-
hot: true,
47+
hot: true
5848
},
5949

6050
mode: isProduction ? 'production' : 'development',
@@ -99,7 +89,6 @@ module.exports = async (env, argv) => {
9989
]
10090
},
10191

102-
10392
optimization: {
10493
minimize: true,
10594
minimizer: [
@@ -133,17 +122,41 @@ module.exports = async (env, argv) => {
133122

134123
};
135124

136-
// Check if pwa service-worker is available
137-
try {
138-
const serviceWorkerPath = './node_modules/@cocreate/pwa/src/service-worker.js';
139-
const access = util.promisify(fs.access);
140-
await access(serviceWorkerPath, fs.constants.F_OK);
141-
config.entry['service-worker'] = serviceWorkerPath
142-
} catch (error) {
143-
console.error('PWA service-worker.js does not exist');
125+
// Hook into the 'done' event of the compiler to execute code when the build is complete.
126+
if (!isProduction) {
127+
config.plugins.push({
128+
apply: (compiler) => {
129+
// console.log('Webpack build is complete in development mode!');
130+
symlink('./dist', '../dist', 'dir')
131+
symlink('./node_modules/@cocreate/pwa/src/service-worker.js', '../service-worker.js', 'file')
132+
symlink('./node_modules/@cocreate/pwa/src/manifest.webmanifest', '../manifest.webmanifest', 'file')
133+
symlink('./node_modules/@cocreate/pwa/src/offline.html', '../offline.html', 'file')
134+
},
135+
});
136+
}
137+
138+
if (isWatch) {
139+
upload(__dirname, ['../', '-w'])
144140
}
145141

146142
return config;
147143

148144
}
149145

146+
function symlink(target, destination, option) {
147+
if (fs.existsSync(target)) {
148+
target = path.resolve(target)
149+
150+
if (!fs.existsSync(destination)) {
151+
destination = path.resolve(destination)
152+
153+
fs.symlink(target, destination, option, (err) => {
154+
if (err)
155+
console.log(err);
156+
else
157+
console.log("symlink added: ", target);
158+
})
159+
160+
}
161+
}
162+
}

0 commit comments

Comments
 (0)