-
Notifications
You must be signed in to change notification settings - Fork 6
/
webpack.plugins.js
68 lines (66 loc) · 2.59 KB
/
webpack.plugins.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
const ForkTsCheckerWebpackPlugin = require('fork-ts-checker-webpack-plugin');
const OptimizeCssnanoPlugin = require('@intervolga/optimize-cssnano-plugin');
const CopyPlugin = require('copy-webpack-plugin');
const { DefinePlugin, ProvidePlugin } = require('webpack');
const path = require('path');
// const puppeteer = require('puppeteer');
// const exec = require('child_process').exec;
/**
* The copyPlugin is used to add some necessary assets to the final bundle. The downloading and bundling puppeteer was
* a way to overcome the limitations of electron and puppeteer-in-electron, but resulted in a huge app with several
* hundred MB size. After a puppeteer-independent solution for the PDF/PNG export was found the puppeteer the
* .local-chromium instance does not need to be included any more, the plugin-setup will be left here first for
* reference.
*/
module.exports = {
forkTsCheckerWebpackPlugin: new ForkTsCheckerWebpackPlugin(),
optimizeCssnanoPlugin: new OptimizeCssnanoPlugin({}),
provideJqueryPlugin: new ProvidePlugin({
$: 'jquery',
jquery: 'jquery',
'window.jQuery': 'jquery',
jQuery:'jquery'
}),
copyPlugin: new CopyPlugin({
patterns: [
// This fix missing assets for html-docx-js
{
from: path.resolve(__dirname, 'node_modules/html-docx-js/build/assets'),
to: path.resolve(__dirname, '.webpack/main/assets'),
},
// This fix missing styling and template for jsonresume-theme-flat
{
from: path.resolve(__dirname, 'node_modules/jsonresume-theme-flat/style.css'),
to: path.resolve(__dirname, '.webpack/main/'),
},
{
from: path.resolve(__dirname, 'node_modules/jsonresume-theme-flat/resume.template'),
to: path.resolve(__dirname, '.webpack/main/'),
},
/*
{
from: path.resolve(__dirname, puppeteer.executablePath().split('/.local-chromium')[0], '.local-chromium'),
to: path.resolve(__dirname, '.webpack/main/chromium'),
globOptions: {
followSymbolicLinks: false,
}
},
*/
],
}),
runShellAfterEmitPlugin: {
/*
apply: (compiler) => {
compiler.hooks.afterEmit.tap('AfterEmitPlugin', (compilation) => {
exec(`chmod -R 755 ${path.resolve(__dirname, '.webpack/main/chromium/')}`, (err, stdout, stderr) => {
if (stdout) process.stdout.write(stdout);
if (stderr) process.stderr.write(stderr);
});
});
},
*/
},
definePlugin: new DefinePlugin({
// CHROMIUM_BINARY: JSON.stringify(path.join('chromium', puppeteer.executablePath().split('/.local-chromium/')[1])),
}),
};