forked from OvidijusParsiunas/myvision
-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
90 lines (88 loc) · 2.43 KB
/
webpack.config.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
const FailOnErrorsPlugin = require('fail-on-errors-webpack-plugin');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const CopyWebpackPlugin = require('copy-webpack-plugin');
const CNAMEWebpackPlugin = require('cname-webpack-plugin');
const ESLintPlugin = require('eslint-webpack-plugin');
const path = require('path');
const env = process.env.NODE_ENV || 'development';
module.exports = () => {
let plugins = [];
let config = {};
if (env === 'production') {
config = {
loggingLevel: 'normal',
outputDirectory: 'tempDeployFolder',
outputFileName: '[name].[contenthash].js',
externalsFileExtension: '.min.js',
externalsDirectory: 'externalsProd',
};
plugins = plugins.concat([
new CNAMEWebpackPlugin({
domain: 'myvision.ai',
})]);
} else {
config = {
loggingLevel: { assets: false, modules: false, children: false },
outputDirectory: 'publicDev',
outputFileName: '[name].js',
externalsFileExtension: '.js',
externalsDirectory: 'externalsDev',
};
}
plugins = plugins.concat([
new FailOnErrorsPlugin({
failOnErrors: true,
failOnWarnings: true,
}),
new HtmlWebpackPlugin({
externalsFileExtension: config.externalsFileExtension,
template: 'src/devIndexTemplate.html',
minify: false,
}),
new CopyWebpackPlugin({
patterns: [
{ from: './src/assets/css', to: 'assets/css' },
{ from: './src/assets/images', to: 'assets/images' },
{ from: './src/assets/svg', to: 'assets/svg' },
{ from: `./src/assets/externals/${config.externalsDirectory}`, to: 'assets/externals' },
],
}),
new ESLintPlugin({}),
]);
return {
entry: {
browserSupportBundle: './src/browserSupport/index.js',
appBundle: './src/app/index.js',
},
output: {
filename: config.outputFileName,
path: path.resolve(__dirname, `./${config.outputDirectory}`),
},
externals: {
fabric: 'fabric',
},
module: {
rules: [
{
test: /\.js$/,
exclude: /node_modules/,
use: [
{
loader: 'babel-loader',
options: {
presets: ['@babel/preset-env'],
},
},
],
},
],
},
mode: env,
stats: config.loggingLevel,
plugins,
performance: {
maxEntrypointSize: 345000,
maxAssetSize: 345000,
},
};
};