Skip to content

Commit 32ee4e1

Browse files
authored
Merge pull request #395 from sumocoders/526-cherry-pick-icons
Cherry-pick font awesome icons to reduce js file size
2 parents 5f524fa + ff94434 commit 32ee4e1

File tree

6 files changed

+152
-18
lines changed

6 files changed

+152
-18
lines changed

package-lock.json

Lines changed: 103 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@
1111
"@babel/preset-env": "^7.14.5",
1212
"@fancyapps/fancybox": "^3.4.2",
1313
"@fortawesome/fontawesome-free": "^6.2.1",
14+
"@fortawesome/fontawesome-svg-core": "^6.7.2",
15+
"@fortawesome/free-brands-svg-icons": "^6.7.2",
16+
"@fortawesome/free-regular-svg-icons": "^6.7.2",
17+
"@fortawesome/free-solid-svg-icons": "^6.7.2",
1418
"@popperjs/core": "^2.6.0",
1519
"autoprefixer": "^10.4.14",
1620
"babel-loader": "^8.2.2",

src/Frontend/Core/Header/Header.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,7 @@ public function __construct(KernelInterface $kernel)
141141
$this->addJS('/src/Frontend/Core/Js/frontend.js', true, true, Priority::core());
142142
// @custom for SumoCoders
143143
$this->addJS('/src/Frontend/Core/bundle.js', false, true, Priority::core());
144+
$this->addJS('/src/Frontend/Core/icons.js', false, true, Priority::core());
144145
}
145146

146147
/**
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import { library, dom } from '@fortawesome/fontawesome-svg-core'
2+
3+
// Select icons to import from the corresponding library
4+
// Solid icons
5+
import { faFilter } from '@fortawesome/free-solid-svg-icons'
6+
7+
// Regular icons
8+
// Import { faEnvelope } from '@fortawesome/free-regular-svg-icons'
9+
10+
// Brand icons
11+
// Import { faFacebook } from '@fortawesome/free-brands-svg-icons'
12+
13+
// Add icons to the library to make them available in the frontend
14+
library.add(faFilter)
15+
16+
dom.i2svg()
17+
dom.watch()

src/Frontend/Themes/Bootstrap/src/Js/Index.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
// /* External library imports */
22
import * as bootstrap from 'bootstrap5/dist/js/bootstrap.js'
3-
import '@fortawesome/fontawesome-free/js/all'
43
// import '@fancyapps/fancybox/dist/jquery.fancybox'
54
// /* Utilities imports */
65
import { ScrollTo } from './Utilities/ScrollTo'

webpack.common.js

Lines changed: 27 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,37 @@
1-
const path = require("path");
1+
const path = require('path')
22
const MiniCssExtractPlugin = require('mini-css-extract-plugin')
3-
const CopyPlugin = require("copy-webpack-plugin")
3+
const CopyPlugin = require('copy-webpack-plugin')
44
const BrowserSyncPlugin = require('browser-sync-webpack-plugin')
55
const PackageJson = require('./package.json')
66
const theme = PackageJson.theme
77

88
module.exports = {
99
entry: {
10+
bundle: [
11+
`./src/Frontend/Themes/${theme}/src/Js/Index.js`
12+
],
13+
icons: [
14+
`./src/Frontend/Themes/${theme}/src/Js/Icons.js`
15+
],
1016
screen: [
11-
`./src/Frontend/Themes/${theme}/src/Js/Index.js`,
1217
`./src/Frontend/Themes/${theme}/src/Layout/Sass/screen.scss`
18+
],
19+
editor_content: [
20+
`./src/Frontend/Themes/${theme}/src/Layout/Sass/editor_content.scss`
1321
]
1422
},
1523
output: {
16-
filename: 'bundle.js',
24+
chunkFilename: (pathData) => {
25+
return pathData.chunk.name === 'bundle' ? 'bundle.js' : '[name].js'
26+
},
1727
path: path.resolve(__dirname, `src/Frontend/Themes/${theme}/Core`),
18-
clean: true,
28+
clean: true
1929
},
20-
mode: "development",
30+
mode: 'development',
2131
externals: ['jquery'],
2232
watchOptions: {
2333
aggregateTimeout: 600,
24-
ignored: /node_modules/,
34+
ignored: /node_modules/
2535
},
2636
plugins: [
2737
new MiniCssExtractPlugin({
@@ -30,16 +40,16 @@ module.exports = {
3040
new CopyPlugin({
3141
patterns: [
3242
{
33-
from: "./Layout/Templates/**/*",
34-
context: path.resolve(__dirname, "src", "Frontend", "Themes", theme, "src"),
43+
from: './Layout/Templates/**/*',
44+
context: path.resolve(__dirname, 'src', 'Frontend', 'Themes', theme, 'src')
3545
},
3646
{
37-
from: "./Layout/Images/**/*",
38-
context: path.resolve(__dirname, "src", "Frontend", "Themes", theme, "src"),
47+
from: './Layout/Images/**/*',
48+
context: path.resolve(__dirname, 'src', 'Frontend', 'Themes', theme, 'src')
3949
}
40-
],
50+
]
4151
}),
42-
// This setup assumes symfony server is running on https://127.0.0.1:8000. If that is not the case, edit "proxy" below.
52+
// This setup assumes symfony server is running on https://127.0.0.1:8000. If that is not the case, edit 'proxy' below.
4353
new BrowserSyncPlugin({
4454
host: '127.0.0.1',
4555
port: 3000,
@@ -72,7 +82,7 @@ module.exports = {
7282
{
7383
loader: 'sass-loader',
7484
options: {
75-
sourceMap: true,
85+
sourceMap: true
7686
}
7787
}
7888
]
@@ -85,9 +95,9 @@ module.exports = {
8595
test: /\.(woff(2)?|ttf|svg|eot)$/,
8696
type: 'asset/resource',
8797
generator: {
88-
filename: './Layout/Fonts/[name][ext]',
89-
},
90-
},
98+
filename: './Layout/Fonts/[name][ext]'
99+
}
100+
}
91101
]
92102
}
93103
}

0 commit comments

Comments
 (0)