-
Notifications
You must be signed in to change notification settings - Fork 156
Expand file tree
/
Copy pathwebpack.config.js
More file actions
61 lines (50 loc) · 1.92 KB
/
webpack.config.js
File metadata and controls
61 lines (50 loc) · 1.92 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
const path = require('path');
const Encore = require('@symfony/webpack-encore');
const pluginName = 'cms';
const createConfigs = (pluginName, options = {}) => {
const defaultOptions = {
wysiwyg: 'ckeditor',
};
const mergedOptions = {...defaultOptions, ...options};
const getConfig = (type) => {
Encore.reset();
let entryFile = 'entry.js';
if (type !== 'shop') {
entryFile = mergedOptions.wysiwyg === 'trix'
? 'trix-entry.js'
: 'entry.js';
}
Encore
.setOutputPath(`public/build/bitbag/${pluginName}/${type}/`)
.setPublicPath(`/build/bitbag/${pluginName}/${type}/`)
.addEntry(
`bitbag-${pluginName}-${type}`,
path.resolve(__dirname, `./src/Resources/assets/${type}/${entryFile}`)
)
.disableSingleRuntimeChunk()
.cleanupOutputBeforeBuild()
.enableSourceMaps(!Encore.isProduction())
.enableSassLoader();
const config = Encore.getWebpackConfig();
config.name = `bitbag-${pluginName}-${type}`;
return config;
};
return [
getConfig('shop'),
getConfig('admin')
];
};
Encore.setOutputPath(`src/Resources/public/build/`)
.setPublicPath(`/public/build/`)
.addEntry(`bitbag-${pluginName}-shop`, path.resolve(__dirname, `./src/Resources/assets/shop/entry.js`))
// Ckeditor
.addEntry(`bitbag-${pluginName}-admin`, path.resolve(__dirname, `./src/Resources/assets/admin/entry.js`))
// Trix
// .addEntry(`bitbag-${pluginName}-admin`, path.resolve(__dirname, `./src/Resources/assets/admin/trix-entry.js`))
.cleanupOutputBeforeBuild()
.disableSingleRuntimeChunk()
.enableSassLoader();
const distConfig = Encore.getWebpackConfig();
distConfig.name = `bitbag-plugin-dist`;
Encore.reset();
module.exports = (options) => createConfigs('cms', options);