webpack
This commit is contained in:
parent
8e6fd04b3a
commit
49cd15a688
19
.vscode/launch.json
vendored
19
.vscode/launch.json
vendored
|
@ -23,7 +23,7 @@
|
|||
"skipFiles": [
|
||||
"<node_internals>/**"
|
||||
],
|
||||
"type": "pwa-node"
|
||||
"type": "node"
|
||||
},
|
||||
{
|
||||
"name": "Data:regionalcities",
|
||||
|
@ -32,7 +32,7 @@
|
|||
"skipFiles": [
|
||||
"<node_internals>/**"
|
||||
],
|
||||
"type": "pwa-node"
|
||||
"type": "node"
|
||||
},
|
||||
{
|
||||
"name": "Data:travelcities",
|
||||
|
@ -41,7 +41,7 @@
|
|||
"skipFiles": [
|
||||
"<node_internals>/**"
|
||||
],
|
||||
"type": "pwa-node"
|
||||
"type": "node"
|
||||
},
|
||||
{
|
||||
"type": "node",
|
||||
|
@ -51,7 +51,18 @@
|
|||
"<node_internals>/**",
|
||||
],
|
||||
"program": "${workspaceFolder}/index.js",
|
||||
"outputCapture": "std",
|
||||
},
|
||||
{
|
||||
"type": "node",
|
||||
"request": "launch",
|
||||
"name": "Server-dist",
|
||||
"skipFiles": [
|
||||
"<node_internals>/**",
|
||||
],
|
||||
"program": "${workspaceFolder}/index.js",
|
||||
"env": {
|
||||
"DIST": "1"
|
||||
}
|
||||
}
|
||||
],
|
||||
"compounds": [
|
||||
|
|
390
dist/index.html
vendored
390
dist/index.html
vendored
File diff suppressed because one or more lines are too long
2
dist/resources/data.min.js
vendored
2
dist/resources/data.min.js
vendored
File diff suppressed because one or more lines are too long
36
dist/resources/vendor.min.js
vendored
Normal file
36
dist/resources/vendor.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
38
dist/resources/ws.min.js
vendored
38
dist/resources/ws.min.js
vendored
File diff suppressed because one or more lines are too long
1
dist/resources/ws.min.js.map
vendored
Normal file
1
dist/resources/ws.min.js.map
vendored
Normal file
File diff suppressed because one or more lines are too long
|
@ -7,6 +7,9 @@ const rename = require('gulp-rename');
|
|||
const htmlmin = require('gulp-htmlmin');
|
||||
const del = require('del');
|
||||
const s3Upload = require('gulp-s3-upload');
|
||||
const webpack = require('webpack-stream');
|
||||
const TerserPlugin = require('terser-webpack-plugin');
|
||||
const path = require('path');
|
||||
|
||||
const clean = () => del(['./dist**']);
|
||||
|
||||
|
@ -22,40 +25,71 @@ const jsSourcesData = [
|
|||
'server/scripts/data/stations.js',
|
||||
'server/scripts/data/states.js',
|
||||
];
|
||||
|
||||
const webpackOptions = {
|
||||
mode: 'production',
|
||||
// mode: 'development',
|
||||
// devtool: 'source-map',
|
||||
output: {
|
||||
filename: 'ws.min.js',
|
||||
},
|
||||
resolve: {
|
||||
roots: [path.resolve(__dirname, './')],
|
||||
},
|
||||
optimization: {
|
||||
minimize: true,
|
||||
minimizer: [
|
||||
new TerserPlugin({
|
||||
extractComments: false,
|
||||
terserOptions: {
|
||||
// sourceMap: true,
|
||||
format: {
|
||||
comments: false,
|
||||
},
|
||||
},
|
||||
}),
|
||||
],
|
||||
},
|
||||
};
|
||||
|
||||
gulp.task('compress_js_data', () => gulp.src(jsSourcesData)
|
||||
.pipe(concat('data.min.js'))
|
||||
.pipe(terser())
|
||||
.pipe(gulp.dest('./dist/resources')));
|
||||
|
||||
const jsSources = [
|
||||
const jsVendorSources = [
|
||||
'server/scripts/vendor/auto/jquery.js',
|
||||
'server/scripts/vendor/jquery.autocomplete.min.js',
|
||||
'server/scripts/vendor/auto/nosleep.js',
|
||||
'server/scripts/vendor/auto/swiped-events.js',
|
||||
'server/scripts/index.js',
|
||||
'server/scripts/vendor/auto/luxon.js',
|
||||
'server/scripts/vendor/auto/suncalc.js',
|
||||
'server/scripts/modules/weatherdisplay.js',
|
||||
'server/scripts/modules/icons.js',
|
||||
'server/scripts/modules/utilities.js',
|
||||
'server/scripts/modules/currentweather.js',
|
||||
'server/scripts/modules/currentweatherscroll.js',
|
||||
'server/scripts/modules/latestobservations.js',
|
||||
'server/scripts/modules/travelforecast.js',
|
||||
'server/scripts/modules/regionalforecast.js',
|
||||
'server/scripts/modules/localforecast.js',
|
||||
'server/scripts/modules/extendedforecast.js',
|
||||
'server/scripts/modules/almanac.js',
|
||||
'server/scripts/modules/radar.js',
|
||||
'server/scripts/modules/hourly.js',
|
||||
'server/scripts/modules/progress.js',
|
||||
'server/scripts/modules/navigation.js',
|
||||
];
|
||||
gulp.task('compress_js', () => gulp.src(jsSources)
|
||||
.pipe(concat('ws.min.js'))
|
||||
|
||||
gulp.task('compress_js_vendor', () => gulp.src(jsVendorSources)
|
||||
.pipe(concat('vendor.min.js'))
|
||||
.pipe(terser())
|
||||
.pipe(gulp.dest('./dist/resources')));
|
||||
|
||||
const mjsSources = [
|
||||
'server/scripts/modules/currentweatherscroll.mjs',
|
||||
'server/scripts/modules/currentweather.mjs',
|
||||
'server/scripts/modules/almanac.mjs',
|
||||
'server/scripts/modules/icons.mjs',
|
||||
'server/scripts/modules/extendedforecast.mjs',
|
||||
'server/scripts/modules/hourly.mjs',
|
||||
'server/scripts/modules/latestobservations.mjs',
|
||||
'server/scripts/modules/localforecast.mjs',
|
||||
'server/scripts/modules/radar.mjs',
|
||||
'server/scripts/modules/regionalforecast.mjs',
|
||||
'server/scripts/modules/travelforecast.mjs',
|
||||
'server/scripts/modules/progress.mjs',
|
||||
'server/scripts/index.mjs',
|
||||
];
|
||||
|
||||
gulp.task('build_js', () => gulp.src(mjsSources)
|
||||
.pipe(webpack(webpackOptions))
|
||||
.pipe(gulp.dest('dist/resources')));
|
||||
|
||||
const cssSources = [
|
||||
'server/styles/main.css',
|
||||
];
|
||||
|
@ -93,6 +127,7 @@ const s3 = s3Upload({
|
|||
});
|
||||
const uploadSources = [
|
||||
'dist/**',
|
||||
'!dist/**/*.map',
|
||||
];
|
||||
gulp.task('upload', () => gulp.src(uploadSources, { base: './dist' })
|
||||
.pipe(s3({
|
||||
|
@ -117,4 +152,4 @@ gulp.task('invalidate', async () => cloudfront.createInvalidation({
|
|||
},
|
||||
}).promise());
|
||||
|
||||
module.exports = gulp.series(clean, gulp.parallel('compress_js', 'compress_js_data', 'copy_css', 'compress_html', 'copy_other_files'), 'upload', 'invalidate');
|
||||
module.exports = gulp.series(clean, gulp.parallel('build_js', 'compress_js_data', 'compress_js_vendor', 'copy_css', 'compress_html', 'copy_other_files'));// , 'upload', 'invalidate');
|
||||
|
|
13
index.js
13
index.js
|
@ -30,12 +30,19 @@ const index = (req, res) => {
|
|||
});
|
||||
};
|
||||
|
||||
// main page
|
||||
// debugging
|
||||
if (process.env?.DIST !== '1') {
|
||||
// debugging
|
||||
app.get('/index.html', index);
|
||||
app.get('/', index);
|
||||
|
||||
// fallback
|
||||
app.get('*', express.static(path.join(__dirname, './server')));
|
||||
} else {
|
||||
// distribution
|
||||
app.use('/images', express.static(path.join(__dirname, './server/images')));
|
||||
app.use('/fonts', express.static(path.join(__dirname, './server/fonts')));
|
||||
app.use('/scripts', express.static(path.join(__dirname, './server/scripts')));
|
||||
app.use('/', express.static(path.join(__dirname, './dist')));
|
||||
}
|
||||
|
||||
const server = app.listen(port, () => {
|
||||
console.log(`Server listening on port ${port}`);
|
||||
|
|
1254
package-lock.json
generated
1254
package-lock.json
generated
File diff suppressed because it is too large
Load diff
|
@ -38,7 +38,9 @@
|
|||
"nosleep.js": "^0.12.0",
|
||||
"sass": "^1.54.0",
|
||||
"suncalc": "^1.8.0",
|
||||
"swiped-events": "^1.1.4"
|
||||
"swiped-events": "^1.1.4",
|
||||
"terser-webpack-plugin": "^5.3.6",
|
||||
"webpack-stream": "^7.0.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"eslint": "^8.21.0",
|
||||
|
|
|
@ -188,7 +188,6 @@ class CurrentWeather extends WeatherDisplay {
|
|||
return condition;
|
||||
}
|
||||
}
|
||||
|
||||
const display = new CurrentWeather(0, 'current-weather');
|
||||
registerDisplay(display);
|
||||
|
||||
|
|
|
@ -98,5 +98,6 @@ const drawCondition = (text) => {
|
|||
elem.innerHTML = text;
|
||||
});
|
||||
};
|
||||
|
||||
document.addEventListener('DOMContentLoaded', () => {
|
||||
start();
|
||||
});
|
||||
|
|
|
@ -32,6 +32,7 @@ const init = async () => {
|
|||
document.getElementById('chkAutoRefresh').checked = false;
|
||||
}
|
||||
document.getElementById('chkAutoRefresh').addEventListener('change', autoRefreshChange);
|
||||
generateCheckboxes();
|
||||
};
|
||||
|
||||
const message = (data) => {
|
||||
|
@ -271,11 +272,18 @@ const resetStatuses = () => {
|
|||
const registerDisplay = (display) => {
|
||||
displays[display.navId] = display;
|
||||
|
||||
// generate checkboxes
|
||||
generateCheckboxes();
|
||||
};
|
||||
|
||||
const generateCheckboxes = () => {
|
||||
const availableDisplays = document.getElementById('enabledDisplays');
|
||||
|
||||
if (!availableDisplays) return;
|
||||
// generate checkboxes
|
||||
const checkboxes = displays.map((d) => d.generateCheckbox()).filter((d) => d);
|
||||
|
||||
// write to page
|
||||
const availableDisplays = document.getElementById('enabledDisplays');
|
||||
availableDisplays.innerHTML = '';
|
||||
availableDisplays.append(...checkboxes);
|
||||
};
|
||||
|
|
|
@ -16,10 +16,11 @@ class Progress extends WeatherDisplay {
|
|||
// disable any navigation timing
|
||||
this.timing = false;
|
||||
|
||||
// setup event listener for dom-required initialization
|
||||
document.addEventListener('DOMContentLoaded', () => {
|
||||
this.version = document.getElementById('version').innerHTML;
|
||||
|
||||
// setup event listener
|
||||
this.elem.querySelector('.container').addEventListener('click', this.lineClick.bind(this));
|
||||
});
|
||||
|
||||
this.okToDrawCurrentConditions = false;
|
||||
}
|
||||
|
|
|
@ -41,7 +41,9 @@ class WeatherDisplay {
|
|||
this.startNavCount();
|
||||
|
||||
// get any templates
|
||||
document.addEventListener('DOMContentLoaded', () => {
|
||||
this.loadTemplates();
|
||||
});
|
||||
}
|
||||
|
||||
generateCheckbox(defaultEnabled = true) {
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
<% if (production) { %>
|
||||
<link rel="stylesheet" type="text/css" href="resources/ws.min.css?_=<%=production%>" />
|
||||
<script type="text/javascript" src="resources/data.min.js?_=<%=production%>"></script>
|
||||
<script type="text/javascript" src="resources/vendor.min.js?_=<%=production%>"></script>
|
||||
<script type="text/javascript" src="resources/ws.min.js?_=<%=production%>"></script>
|
||||
<script type="text/javascript" src="scripts/custom.js?_=<%=production%>"></script>
|
||||
<% } else { %>
|
||||
|
@ -27,24 +28,19 @@
|
|||
<script type="text/javascript" src="scripts/vendor/jquery.autocomplete.min.js"></script>
|
||||
<script type="text/javascript" src="scripts/vendor/auto/nosleep.js"></script>
|
||||
<script type="text/javascript" src="scripts/vendor/auto/swiped-events.js"></script>
|
||||
<script type="module" src="scripts/modules/navigation.mjs"></script>
|
||||
<script type="text/javascript" src="scripts/vendor/auto/suncalc.js"></script>
|
||||
<script type="module" src="scripts/modules/currentweatherscroll.mjs"></script>
|
||||
|
||||
<!-- to be removed-->
|
||||
<script type="module" src="scripts/modules/status.mjs"></script>
|
||||
<script type="module" src="scripts/modules/currentweather.mjs"></script>
|
||||
<script type="module" src="scripts/modules/almanac.mjs"></script>
|
||||
<script type="module" src="scripts/modules/icons.mjs"></script>
|
||||
<script type="module" src="scripts/modules/extendedforecast.mjs"></script>
|
||||
<script type="module" src="scripts/modules/hourly.mjs"></script>
|
||||
<script type="module" src="scripts/modules/progress.mjs"></script>
|
||||
<script type="module" src="scripts/modules/latestobservations.mjs"></script>
|
||||
<script type="module" src="scripts/modules/localforecast.mjs"></script>
|
||||
<script type="module" src="scripts/modules/radar.mjs"></script>
|
||||
<script type="module" src="scripts/modules/regionalforecast.mjs"></script>
|
||||
<script type="module" src="scripts/modules/travelforecast.mjs"></script>
|
||||
<script type="module" src="scripts/modules/weatherdisplay.mjs"></script>
|
||||
|
||||
<script type="module" src="scripts/modules/progress.mjs"></script>
|
||||
<script type="module" src="scripts/index.mjs"></script>
|
||||
|
||||
<!-- data -->
|
||||
|
@ -53,8 +49,7 @@
|
|||
<script type="text/javascript" src="scripts/data/regionalcities.js"></script>
|
||||
<script type="text/javascript" src="scripts/data/stations.js"></script>
|
||||
|
||||
<script type="text/javascript" src="scripts/vendor/auto/suncalc.js"></script>
|
||||
<script type="text/javascript" src="scripts/custom.js?_=<%=production%>"></script>
|
||||
<script type="text/javascript" src="scripts/custom.js"></script>
|
||||
|
||||
<% } %>
|
||||
|
||||
|
|
Loading…
Reference in a new issue