-
Notifications
You must be signed in to change notification settings - Fork 58
Expand file tree
/
Copy pathwebpack.config.js
More file actions
100 lines (91 loc) · 3.29 KB
/
Copy pathwebpack.config.js
File metadata and controls
100 lines (91 loc) · 3.29 KB
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
91
92
93
94
95
96
97
98
99
100
const path = require('path');
const sass = require('sass');
const CopyWebpackPlugin = require('copy-webpack-plugin');
async function sassRender(options) {
const result = await sass.compileAsync(options.file, {
style: 'compressed',
});
return {
css: result.css,
};
}
module.exports = () => {
return {
mode: 'production', // since you explicitly run build for production
devtool: 'cheap-source-map',
entry: {
editor_backend: './js/src/editor/backend/index.js',
editor_frontend: './js/src/editor/frontend/index.js',
client_backend: './js/src/client/backend/index.js',
client_frontend: './js/src/client/frontend/index.js',
},
output: {
filename: '[name].min.js',
path: path.resolve(__dirname, './js/dist'),
},
plugins: [
new CopyWebpackPlugin({
patterns: [
// 1. FRONTEND CORE CSS: Target the single file (Fixed the directory-to-file bug)
{
from: './css/src/frontend/index.css',
to: '../../css/dist/frontend.min.css',
async transform(content, filepath) {
const result = await sassRender({
file: filepath,
});
return result.css.toString();
},
},
// 2. FRONTEND PLUGINS CSS: Added to compile frontend plugin styles.
// NOTE: If this file does not exist, you must create an empty file named plugins.css in the source folder.
{
from: './css/src/frontend/plugins.css',
to: '../../css/dist/frontend.plugins.min.css',
async transform(content, filepath) {
const result = await sassRender({
file: filepath,
});
return result.css.toString();
},
},
// 3. BUILDER CORE CSS: Target the single file (Fixed the directory-to-file bug)
{
from: './css/src/builder/index.css',
to: '../../css/dist/builder.min.css',
async transform(content, filepath) {
const result = await sassRender({
file: filepath,
});
return result.css.toString();
},
},
// 4. BUILDER PLUGINS CSS: Added to compile builder plugin styles.
// NOTE: If this file does not exist, you must create an empty file named plugins.css in the source folder.
{
from: './css/src/builder/plugins.css',
to: '../../css/dist/builder.plugins.min.css',
async transform(content, filepath) {
const result = await sassRender({
file: filepath,
});
return result.css.toString();
},
},
// 4. BUILDER PLUGINS CSS: Added to compile builder plugin styles.
// NOTE: If this file does not exist, you must create an empty file named font-awesome.css in the source folder.
{
from: './css/font-awesome.css',
to: '../../css/font-awesome.min.css',
async transform(content, filepath) {
const result = await sassRender({
file: filepath,
});
return result.css.toString();
},
},
],
}),
],
};
};