-
Notifications
You must be signed in to change notification settings - Fork 12
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
Add CSS hot-reloading #2050
base: main
Are you sure you want to change the base?
Add CSS hot-reloading #2050
Changes from all commits
a0fa972
c33c231
f16ec77
35b2903
db9589f
a1d4cc4
88af738
afb532d
b2929e9
9f17a59
0e1cbdd
defd008
30610ab
ac8ccc3
0dc5aa5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
This file was deleted.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
This file was deleted.
This file was deleted.
This file was deleted.
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,11 +12,11 @@ plugins.addSrc = require("gulp-add-src"); | |
plugins.babel = require("gulp-babel"); | ||
plugins.base64 = require("gulp-base64-inline"); | ||
plugins.concat = require("gulp-concat"); | ||
plugins.faMinify = require("gulp-fa-minify"); | ||
plugins.cleanCSS = require('gulp-clean-css'); | ||
plugins.jshint = require("gulp-jshint"); | ||
plugins.prettyerror = require("gulp-prettyerror"); | ||
plugins.rename = require("gulp-rename"); | ||
//plugins.uglify = require("gulp-uglify"); | ||
plugins.uglify = require("gulp-uglify"); | ||
|
||
// 2. CONFIGURATION | ||
// - - - - - - - - - - - - - - - | ||
|
@@ -86,35 +86,44 @@ const javascripts = () => { | |
"accessible-autocomplete/dist/accessible-autocomplete.min.js", | ||
]) | ||
) | ||
//.pipe(plugins.uglify()) | ||
.pipe(plugins.uglify()) | ||
.pipe(plugins.concat("all.min.js")) | ||
.pipe( | ||
plugins.addSrc.prepend([ | ||
paths.src + "javascripts/main.min.js", | ||
paths.src + "javascripts/index.min.js", | ||
paths.src + "javascripts/scheduler.min.js", | ||
paths.src + "javascripts/branding_request.min.js", | ||
paths.src + "javascripts/formValidateRequired.min.js", | ||
paths.src + "javascripts/sessionRedirect.min.js", | ||
paths.src + "javascripts/touDialog.min.js", | ||
paths.src + "javascripts/templateFilters.min.js", | ||
]) | ||
) | ||
.pipe(dest(paths.dist + "javascripts/")); | ||
}; | ||
|
||
const minifyIndividualJs = () => { | ||
return src([ | ||
paths.src + "javascripts/branding_request.js", | ||
paths.src + "javascripts/formValidateRequired.js", | ||
paths.src + "javascripts/sessionRedirect.js", | ||
paths.src + "javascripts/touDialog.js", | ||
paths.src + "javascripts/templateFilters.js" | ||
Comment on lines
+102
to
+106
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Are these ever bundled? Do we load them piece by piece in our html templates? If not, we could remove this step? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These few are not bundled. The thought when they were created was that since they are not often used, they could exist separately. Although, the templateFilters one probably should be bundled now that I look more closely. |
||
]) | ||
.pipe(plugins.prettyerror()) | ||
.pipe(plugins.babel({ | ||
presets: ["@babel/preset-env"] | ||
})) | ||
.pipe(plugins.uglify()) | ||
.pipe(plugins.rename({ suffix: '.min' })) | ||
.pipe(dest(paths.dist + "javascripts/")); | ||
}; | ||
|
||
// copy static css | ||
const static_css = () => { | ||
return src(paths.src + "/stylesheets/index.css") | ||
.pipe( | ||
plugins.addSrc.prepend([ | ||
paths.npm + "accessible-autocomplete/dist/accessible-autocomplete.min.css", | ||
paths.src + "stylesheets/fa-svg-with-js.css", | ||
]) | ||
) | ||
.pipe(plugins.concat("index.css")) | ||
.pipe( | ||
dest(paths.dist + "stylesheets/") | ||
); | ||
.pipe(plugins.cleanCSS({ | ||
level: 2, | ||
}, (details) => { | ||
console.log(`${details.name}: Original size:${details.stats.originalSize} - Minified size: ${details.stats.minifiedSize}`) | ||
amazingphilippe marked this conversation as resolved.
Show resolved
Hide resolved
|
||
})) | ||
.pipe(dest(paths.dist + "stylesheets/")); | ||
}; | ||
|
||
// Copy images | ||
|
@@ -144,7 +153,7 @@ const watchFiles = { | |
|
||
// Default: compile everything | ||
const defaultTask = parallel( | ||
series(javascripts), | ||
series(minifyIndividualJs, javascripts), | ||
series(images), | ||
series(static_css), | ||
); | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,9 +9,9 @@ | |
"test": "jest --config tests/javascripts/jest.config.js tests/javascripts", | ||
"webpack": "webpack --config webpack.config.js", | ||
"build": "gulp", | ||
"watch": "gulp watch", | ||
"watch": "npx tailwindcss -i ./app/assets/stylesheets/tailwind/style.css -o ./app/static/stylesheets/index.css --watch ", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we need gulp in there? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nope - all the css is within styles.css now and we shouldnt add arbitrary css to gulp anymore. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So watch will only update on css changes, and not script changes? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah - I didnt tackle watching the js - could be another PR! |
||
"heroku-postbuild": "gulp && make generate-version-file && export ADMIN_BASE_URL=${HEROKU_APP_NAME}.herokuapp.com", | ||
"tailwind": "webpack --config webpack.config.js && gulp" | ||
"tailwind": "npx tailwindcss -i ./app/assets/stylesheets/tailwind/style.css -o ./app/assets/stylesheets/index.css --minify && webpack --config webpack.config.js && gulp" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
|
@@ -57,6 +57,7 @@ | |
"gulp-add-src": "1.0.0", | ||
"gulp-babel": "8.0.0", | ||
"gulp-base64-inline": "1.0.6", | ||
"gulp-clean-css": "^4.3.0", | ||
"gulp-concat": "2.6.1", | ||
"gulp-fa-minify": "^6.0.1", | ||
"gulp-include": "2.4.1", | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,12 +7,7 @@ module.exports = { | |
// mode: "development", //development | ||
mode: "production", | ||
entry: { | ||
main: ["./app/assets/javascripts/index.js", "./app/assets/stylesheets/tailwind/style.css"], | ||
branding_request: ["./app/assets/javascripts/branding_request.js"], | ||
formValidateRequired: ["./app/assets/javascripts/formValidateRequired.js"], | ||
sessionRedirect: ["./app/assets/javascripts/sessionRedirect.js"], | ||
touDialog: ["./app/assets/javascripts/touDialog.js"], | ||
templateFilters: ["./app/assets/javascripts/templateFilters.js"], | ||
index: ["./app/assets/javascripts/index.js"], | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. lovely There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah this file being named This is still confusing - but less so :D |
||
scheduler: { | ||
import: './app/assets/javascripts/scheduler/scheduler.js', | ||
library: { | ||
|
@@ -44,17 +39,6 @@ module.exports = { | |
], | ||
use: ["style-loader", "css-loader"] | ||
}, | ||
{ | ||
test: /\.css$/i, | ||
include: [ | ||
path.resolve(__dirname, "app/assets/stylesheets/tailwind") | ||
], | ||
use: [ | ||
MiniCssExtractPlugin.loader, | ||
"css-loader", | ||
"postcss-loader" | ||
] | ||
}, | ||
Comment on lines
-47
to
-57
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good riddance! |
||
{ test: /\.(png|svg|jpg|gif|ico)$/, use: ["file-loader"] }, | ||
{ | ||
test: /.(js|jsx)$/, | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need to load both "index" and "all"? It seems like we prepend all with index in gulpfile.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We dont combine them - but i have no idea why. I think we probably could just have the one.