Skip to content

Commit 1c2c46b

Browse files
committed
minor #8055 [Front-End] Adding note about extracting CSS (weaverryan)
This PR was merged into the 3.3 branch. Discussion ---------- [Front-End] Adding note about extracting CSS In Encore, the `createSharedEntry()` can also include CSS. See symfony/webpack-encore#20 Commits ------- 99f9b3a adding note about extracting CSS
2 parents 7abe4c3 + 99f9b3a commit 1c2c46b

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

frontend/encore/shared-entry.rst

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,14 @@ that's included on every page:
1515
1616
// this creates a 'vendor.js' file with jquery and the bootstrap JS module
1717
// these modules will *not* be included in page1.js or page2.js anymore
18-
.createSharedEntry('vendor', ['jquery', 'bootstrap'])
18+
.createSharedEntry('vendor', [
19+
'jquery',
20+
'bootstrap',
21+
22+
// you can also extract CSS - this will create a 'vendor.css' file
23+
// this CSS will *not* be included in page1.css or page2.css anymore
24+
'bootstrap-sass/assets/stylesheets/_bootstrap.scss'
25+
])
1926
2027
As soon as you make this change, you need to include two extra JavaScript files
2128
on your page before any other JavaScript file:
@@ -29,6 +36,9 @@ on your page before any other JavaScript file:
2936
<!-- here you link to the specific JS files needed by the current page -->
3037
<script src="{{ asset('build/app.js') }}"></script>
3138
39+
<!-- if you extracted some CSS, include vendor.css -->
40+
<link rel="stylesheet" href="{{ asset('build/vendor.css') }}" />
41+
3242
The ``vendor.js`` file contains all the common code that has been extracted from
3343
the other files, so it's obvious that it must be included. The other file (``manifest.js``)
3444
is less obvious: it's needed so that Webpack knows how to load those shared modules.

0 commit comments

Comments
 (0)