Skip to content

Commit e4e8e26

Browse files
Josh SagerGitHub Enterprise
authored andcommitted
Merge pull request linode#27 from abailly/DCL-61-prod-deplyment-setup
DLC-61 - ignore css bundle and better gulp setup
2 parents 1d7517d + 278cfd9 commit e4e8e26

File tree

5 files changed

+209
-1562
lines changed

5 files changed

+209
-1562
lines changed

themes/dlc/.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
node_modules
22
yarn-error.log
33
.DS_Store
4-
/static/assets/cssinfo/
4+
/static/assets/css/main.css
5+
/static/assets/cssinfo/
6+
/styleguide

themes/dlc/gulpfile.js

Lines changed: 37 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ const cssInfo = require('gulp-css-info');
99
const cssnano = require('cssnano');
1010
const stylelint = require('stylelint');
1111
const reporter = require('postcss-reporter');
12+
const size = require('gulp-size');
13+
const notify = require('gulp-notify');
1214

1315
const tailwind = 'tailwind.js';
1416
const mainCss = './srcCSS/main.css';
@@ -31,13 +33,13 @@ const plugins = [
3133
autoprefixer({
3234
browsers: ['last 2 versions', '> 2%']
3335
}),
34-
// cssnano({
35-
// preset: ['none', {
36-
// discardComments: {
37-
// removeAll: true,
38-
// },
39-
// }]
40-
// })
36+
cssnano({
37+
preset: ['default', {
38+
discardComments: {
39+
removeAll: true,
40+
},
41+
}]
42+
})
4143
];
4244

4345
gulp.task('lint', () => {
@@ -56,6 +58,7 @@ gulp.task('cssInfo', () => {
5658
});
5759

5860
gulp.task('compile', () => {
61+
const s = size();
5962
return gulp.src(mainCss)
6063
.pipe(plumber())
6164
.pipe(postcss(plugins))
@@ -71,7 +74,32 @@ gulp.task('compile', () => {
7174
]
7275
})
7376
)
74-
.pipe(gulp.dest(output));
77+
.pipe(gulp.dest(output))
78+
});
79+
80+
gulp.task('size', () => {
81+
const s = size();
82+
return gulp.src(mainCss)
83+
.pipe(plumber())
84+
.pipe(postcss(plugins))
85+
.pipe(
86+
purgecss({
87+
content: [baseThemeHtml, html],
88+
whitelist: ['mobile-nav', 'active'],
89+
extractors: [
90+
{
91+
extractor: TailwindExtractor,
92+
extensions: ["html"]
93+
}
94+
]
95+
})
96+
)
97+
.pipe(s)
98+
.pipe(notify({
99+
onLast: true,
100+
message: () =>
101+
`Compiled!\nCSS bundle size: ${s.prettySize}`
102+
}));
75103
});
76104

77105
gulp.task('watch:css', () => {
@@ -90,5 +118,5 @@ gulp.task('watch:tailwind', () => {
90118
gulp.watch(tailwind, ['compile']);
91119
});
92120

93-
gulp.task('default', ['lint', 'compile', 'cssInfo']);
121+
gulp.task('default', ['lint', 'compile', 'cssInfo', 'size']);
94122
gulp.task('watch', ['compile', 'watch:basecss', 'watch:css', 'watch:html', 'watch:tailwind']);

themes/dlc/package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,16 @@
88
"glob": "^7.1.2",
99
"gulp": "^3.9.1",
1010
"gulp-css-info": "^1.0.1",
11+
"gulp-notify": "^3.2.0",
1112
"gulp-plumber": "^1.2.0",
1213
"gulp-postcss": "^7.0.1",
1314
"gulp-purgecss": "^1.0.0",
15+
"gulp-size": "^3.0.0",
1416
"gulp-watch": "^5.0.0",
1517
"postcss": "^6.0.14",
1618
"postcss-easy-import": "^3.0.0",
1719
"postcss-reporter": "^5.0.0",
20+
"react-patterns": "^3.0.7",
1821
"stylelint": "^9.3.0",
1922
"stylelint-config-standard": "^18.2.0",
2023
"tailwindcss": "^0.5.3"

0 commit comments

Comments
 (0)