This repository has been archived by the owner on Oct 10, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathwebpack.config.js
67 lines (65 loc) · 2.32 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
let Encore = require('@symfony/webpack-encore');
let Glob = require('glob-all');
let Path = require('path');
let ExtractTextPlugin = require("extract-text-webpack-plugin");
let PurgeCssPlugin = require('purgecss-webpack-plugin');
let FaviconsWebpackPlugin = require('favicons-webpack-plugin');
let CopyWebpackPlugin = require('copy-webpack-plugin');
let { VueLoaderPlugin } = require('vue-loader');
// https://github.com/FullHuman/purgecss#extractor
Encore.setOutputPath('public/build/')
.setPublicPath('/build')
.cleanupOutputBeforeBuild()
.addEntry('js/app', './assets/js/app.js')
.addStyleEntry('css/app', './assets/scss/app.scss')
.enableSassLoader(function (sassOptions){}, {
resolveUrlLoader: false
})
.enablePostCssLoader((options) => {
options.config = {
path: 'postcss.config.js'
};
})
.enableVersioning(Encore.isProduction())
.enableSourceMaps(!Encore.isProduction())
.enableVueLoader()
.addPlugin(
new VueLoaderPlugin()
)
.addPlugin(
new CopyWebpackPlugin([
{
from: 'node_modules/@icon/zondicons/icons/**/*',
to: 'images/zondicons',
flatten: true
}
])
);
if(Encore.isProduction()) {
Encore.addPlugin(new ExtractTextPlugin("css/app.css"))
.addPlugin(new PurgeCssPlugin({
paths: Glob.sync([
Path.join(__dirname, "templates/**/*.twig"),
Path.join(__dirname, "assets/js/**/*.js"),
Path.join(__dirname, "assets/js/**/*.vue")
]),
extractors: [
{
extractor: class {
static extract(content) {
return content.match(/[A-z0-9-:\/]+/g) || []
}
},
extensions: ['html', 'js', 'php', 'twig', 'vue']
}
]
}))
.addPlugin(new FaviconsWebpackPlugin({
logo: './assets/images/master-favicon.png',
prefix: 'favicons-[hash]/',
emitStats: true,
statsFilename: 'favicons.json',
persistentCache: true
}))
}
module.exports = Encore.getWebpackConfig();