Skip to content

Commit 39c9f6d

Browse files
committed
Optimise plugin css
1 parent cc643c5 commit 39c9f6d

File tree

7 files changed

+110
-21
lines changed

7 files changed

+110
-21
lines changed
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
/*
2+
*
3+
* Copyright 2022 Google LLC
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*
17+
*
18+
*/
19+
20+
/*
21+
* All Frontend CSS without importing material-components.css.
22+
*/
23+
@import "./base/variables.css";
24+
@import "./conf/index.css";
25+
@import "typography.css";
26+
@import "./components/contact-form.css";
27+
@import "./components/masonry-grid.css";
28+
@import "./components/card.css";
29+
@import "./components/core.css";
30+
@import "../../src/block-editor/blocks/common-posts-list/style.css";
31+
@import "../../src/block-editor/blocks/contact-form/inner-blocks/common/style.css";
32+
@import "../../src/block-editor/blocks/card/style.css";
33+
@import "./block/style/masonry.css";
34+
@import "./overrides.css";
35+
@import "./tokens/index.css";
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
/**
2+
* Copyright 2020 Google LLC
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
/*
18+
* All Frontend CSS.
19+
*/
20+
@import "material-components-with-active-theme.css";
21+
@import "_frontend.css";

plugin/assets/css/src/front-end.css

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -17,17 +17,5 @@
1717
/*
1818
* All Frontend CSS.
1919
*/
20-
@import "./base/variables.css";
21-
@import "./conf/index.css";
22-
@import "typography.css";
23-
@import "./material-components.css";
24-
@import "./components/contact-form.css";
25-
@import "./components/masonry-grid.css";
26-
@import "./components/card.css";
27-
@import "./components/core.css";
28-
@import "../../src/block-editor/blocks/common-posts-list/style.css";
29-
@import "../../src/block-editor/blocks/contact-form/inner-blocks/common/style.css";
30-
@import "../../src/block-editor/blocks/card/style.css";
31-
@import "./block/style/masonry.css";
32-
@import "./overrides.css";
33-
@import "./tokens/index.css";
20+
@import "material-components.css";
21+
@import "_frontend.css";
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/**
2+
* Copyright 2020 Google LLC
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
/*
18+
* Required Material components when material theme is active.
19+
*/
20+
21+
@import "mixins.css";
22+
@import "@material/icon-button/dist/mdc.icon-button.css";
23+
@import "@material/layout-grid/dist/mdc.layout-grid.css";
24+
@import "@material/tab-bar/dist/mdc.tab-bar.css";
25+
@import "@material/tab-scroller/dist/mdc.tab-scroller.css";
26+
@import "./components/material.css";
27+
@import "./components/datatable.css";
28+
@import "./components/tooltip.css";

plugin/assets/css/src/material-components.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
@import "@material/layout-grid/dist/mdc.layout-grid.css";
2323
@import "@material/tab-bar/dist/mdc.tab-bar.css";
2424
@import "@material/tab-scroller/dist/mdc.tab-scroller.css";
25-
@import "components/image-card.css";
25+
@import "./components/image-card.css";
2626
@import "./components/material.css";
2727
@import "./components/datatable.css";
2828
@import "./components/text-field.css";

plugin/php/class-plugin.php

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -263,12 +263,21 @@ public function enqueue_front_end_assets() {
263263

264264
wp_localize_script( 'material-front-end-js', 'materialDesign', $wp_localized_script_data );
265265

266-
wp_enqueue_style(
267-
'material-front-end-css',
268-
$this->asset_url( 'assets/css/front-end-compiled.css' ),
269-
[],
270-
$this->asset_version()
271-
);
266+
if ( self::THEME_SLUG === get_template() ) {
267+
wp_enqueue_style(
268+
'material-front-end-css',
269+
$this->asset_url( 'assets/css/front-end-w-theme-compiled.css' ),
270+
[],
271+
$this->asset_version()
272+
);
273+
} else {
274+
wp_enqueue_style(
275+
'material-front-end-css',
276+
$this->asset_url( 'assets/css/front-end-compiled.css' ),
277+
[],
278+
$this->asset_version()
279+
);
280+
}
272281

273282
/**
274283
* Enqueue material style overrides if the theme is not material.

webpack.config.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,14 @@ const assets = {
8484
'./plugin/assets/css/src/front-end.css',
8585
],
8686
},
87+
{
88+
name: 'Front End with material theme ', // Remove duplicate css from theme when theme is active.
89+
chunk: 'front-end-w-theme',
90+
entry: [
91+
'./plugin/assets/src/front-end/index.js',
92+
'./plugin/assets/css/src/front-end-with-active-theme.css',
93+
],
94+
},
8795
{
8896
name: 'Admin',
8997
chunk: 'admin',

0 commit comments

Comments
 (0)