Skip to content

[Front-End] Adding note about extracting CSS #8055

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 22, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion frontend/encore/shared-entry.rst
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,14 @@ that's included on every page:

// this creates a 'vendor.js' file with jquery and the bootstrap JS module
// these modules will *not* be included in page1.js or page2.js anymore
.createSharedEntry('vendor', ['jquery', 'bootstrap'])
.createSharedEntry('vendor', [
'jquery',
'bootstrap',

// you can also extract CSS - this will create a 'vendor.css' file
// this CSS will *not* be included in page1.css or page2.css anymore
'bootstrap-sass/assets/stylesheets/_bootstrap.scss'
])
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing trailing semicolon?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

well, this is not broken technically, as the semicolon is optional in JS 😄


As soon as you make this change, you need to include two extra JavaScript files
on your page before any other JavaScript file:
Expand All @@ -29,6 +36,9 @@ on your page before any other JavaScript file:
<!-- here you link to the specific JS files needed by the current page -->
<script src="{{ asset('build/app.js') }}"></script>

<!-- if you extracted some CSS, include vendor.css -->
<link rel="stylesheet" href="{{ asset('build/vendor.css') }}" />

The ``vendor.js`` file contains all the common code that has been extracted from
the other files, so it's obvious that it must be included. The other file (``manifest.js``)
is less obvious: it's needed so that Webpack knows how to load those shared modules.
Expand Down