-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathconfig-builder.js
51 lines (47 loc) · 1.69 KB
/
config-builder.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
var upath = require('upath');
var path = require('path');
var Encore = require('@symfony/webpack-encore');
var build = (name, assetPath, vendorUiPath) => {
Encore
// the project directory where compiled assets will be stored
.setOutputPath(`public/assets/${name}`)
// the public path used by the web server to access the previous directory
.setPublicPath(`/assets/${name}`)
.cleanupOutputBeforeBuild()
.enableSourceMaps(!Encore.isProduction())
.enableVersioning(Encore.isProduction())
// uncomment to define the assets of the project
.addEntry('app', `${assetPath}/js/app.js`)
// uncomment if you use Sass/SCSS files
.enableSassLoader((options) => {
if(name === "backend") {
options.data = '@import "~semantic-ui-css/semantic.min.css";';
}
})
.autoProvidejQuery()
.configureBabel()
.disableSingleRuntimeChunk()
.copyFiles({
from: `${assetPath}/img`,
to: 'img/[path][name].[ext]',
}, {
from: upath.joinSafe(vendorUiPath, 'Resources/private/img'),
to: 'img/[path][name].[ext]',
})
.configureFilenames({
js: 'js/[name].[hash:8].js',
css: 'css/[name].[hash:8].css',
images: 'img/[name].[hash:8].[ext]',
fonts: 'font/[name].[hash:8].[ext]'
});
;
const config = Encore.getWebpackConfig();
config.name = name;
config.resolve.alias = {
'~': path.resolve(__dirname, '../../'),
'sylius/ui': vendorUiPath + '/Resources/private',
};
Encore.reset();
return config;
};
module.exports = build;