Skip to content
Merged
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,17 @@ def scrolled_frontend_javascript_packs_tag(entry, options)

def scrolled_frontend_stylesheet_packs_tag(entry, options)
stylesheet_pack_tag(
*scrolled_frontend_packs(entry, **options),
*scrolled_frontend_stylesheet_packs(entry, **options),
media: 'all'
)
end

def scrolled_frontend_stylesheet_packs(entry, entry_mode:)
packs = scrolled_frontend_packs(entry, entry_mode: entry_mode)
packs += ['pageflow-scrolled-frontend-inlineEditing'] if entry_mode == :editor
packs
end

def scrolled_editor_javascript_packs_tag(entry)
javascript_pack_tag(
*scrolled_editor_packs(entry),
Expand Down
3 changes: 3 additions & 0 deletions entry_types/scrolled/package/config/webpack.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,9 @@ module.exports = {
'pageflow-scrolled/widgets/iconScrollIndicator',
'pageflow-scrolled/widgets/iconScrollIndicator.css'
]
},
'pageflow-scrolled-frontend-inlineEditing': {
import: ['pageflow-scrolled/frontend/inlineEditing.css']
}
}
};
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,33 @@ module PageflowScrolled
end
end

describe 'scrolled_frontend_stylesheet_packs' do
it 'includes core frontend pack' do
entry = create(:published_entry, type_name: 'scrolled')

result = helper.scrolled_frontend_stylesheet_packs(entry,
entry_mode: :published)

expect(result).to include('pageflow-scrolled-frontend')
end

it 'includes inline editing stylesheet pack only in editor mode' do
entry = create(:published_entry, type_name: 'scrolled')

expect(
helper.scrolled_frontend_stylesheet_packs(entry, entry_mode: :editor)
).to include('pageflow-scrolled-frontend-inlineEditing')

expect(
helper.scrolled_frontend_stylesheet_packs(entry, entry_mode: :preview)
).not_to include('pageflow-scrolled-frontend-inlineEditing')

expect(
helper.scrolled_frontend_stylesheet_packs(entry, entry_mode: :published)
).not_to include('pageflow-scrolled-frontend-inlineEditing')
end
end

describe 'scrolled_editor_packs' do
it 'includes editor pack' do
entry = create(:published_entry, type_name: 'scrolled')
Expand Down
20 changes: 17 additions & 3 deletions rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,21 @@ function external(id) {
return !['.', '/', '$'].includes(id[0]);
}

const plugins = ({extractCss, moduleDirectories} = {}) => [
const plugins = ({extractCss, splitCss, moduleDirectories} = {}) => [
postcss({
modules: true,
extract: extractCss,
minimize: extractCss
minimize: extractCss,
...(splitCss && {exclude: Object.keys(splitCss)})
}),
...Object.entries(splitCss || {}).map(([include, output]) =>
postcss({
modules: true,
extract: output,
minimize: true,
include: [include]
})
),
babel({
exclude: 'node_modules/**',
extensions: ['js', 'jsx', 'svg'],
Expand Down Expand Up @@ -264,7 +273,12 @@ const pageflowScrolled = [
format: 'esm',
},
external,
plugins: plugins({extractCss: true}),
plugins: plugins({
extractCss: true,
splitCss: {
'**/inlineEditing/**': pageflowScrolledPackageRoot + '/frontend/inlineEditing.css'
}
}),
...ignoreJSXWarning
},
{
Expand Down
Loading