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": [
|
"skipFiles": [
|
||||||
"<node_internals>/**"
|
"<node_internals>/**"
|
||||||
],
|
],
|
||||||
"type": "pwa-node"
|
"type": "node"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "Data:regionalcities",
|
"name": "Data:regionalcities",
|
||||||
|
@ -32,7 +32,7 @@
|
||||||
"skipFiles": [
|
"skipFiles": [
|
||||||
"<node_internals>/**"
|
"<node_internals>/**"
|
||||||
],
|
],
|
||||||
"type": "pwa-node"
|
"type": "node"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "Data:travelcities",
|
"name": "Data:travelcities",
|
||||||
|
@ -41,7 +41,7 @@
|
||||||
"skipFiles": [
|
"skipFiles": [
|
||||||
"<node_internals>/**"
|
"<node_internals>/**"
|
||||||
],
|
],
|
||||||
"type": "pwa-node"
|
"type": "node"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "node",
|
"type": "node",
|
||||||
|
@ -51,7 +51,18 @@
|
||||||
"<node_internals>/**",
|
"<node_internals>/**",
|
||||||
],
|
],
|
||||||
"program": "${workspaceFolder}/index.js",
|
"program": "${workspaceFolder}/index.js",
|
||||||
"outputCapture": "std",
|
},
|
||||||
|
{
|
||||||
|
"type": "node",
|
||||||
|
"request": "launch",
|
||||||
|
"name": "Server-dist",
|
||||||
|
"skipFiles": [
|
||||||
|
"<node_internals>/**",
|
||||||
|
],
|
||||||
|
"program": "${workspaceFolder}/index.js",
|
||||||
|
"env": {
|
||||||
|
"DIST": "1"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"compounds": [
|
"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 htmlmin = require('gulp-htmlmin');
|
||||||
const del = require('del');
|
const del = require('del');
|
||||||
const s3Upload = require('gulp-s3-upload');
|
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**']);
|
const clean = () => del(['./dist**']);
|
||||||
|
|
||||||
|
@ -22,40 +25,71 @@ const jsSourcesData = [
|
||||||
'server/scripts/data/stations.js',
|
'server/scripts/data/stations.js',
|
||||||
'server/scripts/data/states.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)
|
gulp.task('compress_js_data', () => gulp.src(jsSourcesData)
|
||||||
.pipe(concat('data.min.js'))
|
.pipe(concat('data.min.js'))
|
||||||
.pipe(terser())
|
.pipe(terser())
|
||||||
.pipe(gulp.dest('./dist/resources')));
|
.pipe(gulp.dest('./dist/resources')));
|
||||||
|
|
||||||
const jsSources = [
|
const jsVendorSources = [
|
||||||
'server/scripts/vendor/auto/jquery.js',
|
'server/scripts/vendor/auto/jquery.js',
|
||||||
'server/scripts/vendor/jquery.autocomplete.min.js',
|
'server/scripts/vendor/jquery.autocomplete.min.js',
|
||||||
'server/scripts/vendor/auto/nosleep.js',
|
'server/scripts/vendor/auto/nosleep.js',
|
||||||
'server/scripts/vendor/auto/swiped-events.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/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(terser())
|
||||||
.pipe(gulp.dest('./dist/resources')));
|
.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 = [
|
const cssSources = [
|
||||||
'server/styles/main.css',
|
'server/styles/main.css',
|
||||||
];
|
];
|
||||||
|
@ -93,6 +127,7 @@ const s3 = s3Upload({
|
||||||
});
|
});
|
||||||
const uploadSources = [
|
const uploadSources = [
|
||||||
'dist/**',
|
'dist/**',
|
||||||
|
'!dist/**/*.map',
|
||||||
];
|
];
|
||||||
gulp.task('upload', () => gulp.src(uploadSources, { base: './dist' })
|
gulp.task('upload', () => gulp.src(uploadSources, { base: './dist' })
|
||||||
.pipe(s3({
|
.pipe(s3({
|
||||||
|
@ -117,4 +152,4 @@ gulp.task('invalidate', async () => cloudfront.createInvalidation({
|
||||||
},
|
},
|
||||||
}).promise());
|
}).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');
|
||||||
|
|
19
index.js
19
index.js
|
@ -30,12 +30,19 @@ const index = (req, res) => {
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
// main page
|
// debugging
|
||||||
app.get('/index.html', index);
|
if (process.env?.DIST !== '1') {
|
||||||
app.get('/', index);
|
// debugging
|
||||||
|
app.get('/index.html', index);
|
||||||
// fallback
|
app.get('/', index);
|
||||||
app.get('*', express.static(path.join(__dirname, './server')));
|
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, () => {
|
const server = app.listen(port, () => {
|
||||||
console.log(`Server listening on port ${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",
|
"nosleep.js": "^0.12.0",
|
||||||
"sass": "^1.54.0",
|
"sass": "^1.54.0",
|
||||||
"suncalc": "^1.8.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": {
|
"dependencies": {
|
||||||
"eslint": "^8.21.0",
|
"eslint": "^8.21.0",
|
||||||
|
|
|
@ -188,7 +188,6 @@ class CurrentWeather extends WeatherDisplay {
|
||||||
return condition;
|
return condition;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const display = new CurrentWeather(0, 'current-weather');
|
const display = new CurrentWeather(0, 'current-weather');
|
||||||
registerDisplay(display);
|
registerDisplay(display);
|
||||||
|
|
||||||
|
|
|
@ -98,5 +98,6 @@ const drawCondition = (text) => {
|
||||||
elem.innerHTML = text;
|
elem.innerHTML = text;
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
document.addEventListener('DOMContentLoaded', () => {
|
||||||
start();
|
start();
|
||||||
|
});
|
||||||
|
|
|
@ -32,6 +32,7 @@ const init = async () => {
|
||||||
document.getElementById('chkAutoRefresh').checked = false;
|
document.getElementById('chkAutoRefresh').checked = false;
|
||||||
}
|
}
|
||||||
document.getElementById('chkAutoRefresh').addEventListener('change', autoRefreshChange);
|
document.getElementById('chkAutoRefresh').addEventListener('change', autoRefreshChange);
|
||||||
|
generateCheckboxes();
|
||||||
};
|
};
|
||||||
|
|
||||||
const message = (data) => {
|
const message = (data) => {
|
||||||
|
@ -271,11 +272,18 @@ const resetStatuses = () => {
|
||||||
const registerDisplay = (display) => {
|
const registerDisplay = (display) => {
|
||||||
displays[display.navId] = display;
|
displays[display.navId] = display;
|
||||||
|
|
||||||
|
// generate checkboxes
|
||||||
|
generateCheckboxes();
|
||||||
|
};
|
||||||
|
|
||||||
|
const generateCheckboxes = () => {
|
||||||
|
const availableDisplays = document.getElementById('enabledDisplays');
|
||||||
|
|
||||||
|
if (!availableDisplays) return;
|
||||||
// generate checkboxes
|
// generate checkboxes
|
||||||
const checkboxes = displays.map((d) => d.generateCheckbox()).filter((d) => d);
|
const checkboxes = displays.map((d) => d.generateCheckbox()).filter((d) => d);
|
||||||
|
|
||||||
// write to page
|
// write to page
|
||||||
const availableDisplays = document.getElementById('enabledDisplays');
|
|
||||||
availableDisplays.innerHTML = '';
|
availableDisplays.innerHTML = '';
|
||||||
availableDisplays.append(...checkboxes);
|
availableDisplays.append(...checkboxes);
|
||||||
};
|
};
|
||||||
|
|
|
@ -16,10 +16,11 @@ class Progress extends WeatherDisplay {
|
||||||
// disable any navigation timing
|
// disable any navigation timing
|
||||||
this.timing = false;
|
this.timing = false;
|
||||||
|
|
||||||
this.version = document.getElementById('version').innerHTML;
|
// setup event listener for dom-required initialization
|
||||||
|
document.addEventListener('DOMContentLoaded', () => {
|
||||||
// setup event listener
|
this.version = document.getElementById('version').innerHTML;
|
||||||
this.elem.querySelector('.container').addEventListener('click', this.lineClick.bind(this));
|
this.elem.querySelector('.container').addEventListener('click', this.lineClick.bind(this));
|
||||||
|
});
|
||||||
|
|
||||||
this.okToDrawCurrentConditions = false;
|
this.okToDrawCurrentConditions = false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,7 +41,9 @@ class WeatherDisplay {
|
||||||
this.startNavCount();
|
this.startNavCount();
|
||||||
|
|
||||||
// get any templates
|
// get any templates
|
||||||
this.loadTemplates();
|
document.addEventListener('DOMContentLoaded', () => {
|
||||||
|
this.loadTemplates();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
generateCheckbox(defaultEnabled = true) {
|
generateCheckbox(defaultEnabled = true) {
|
||||||
|
|
|
@ -19,6 +19,7 @@
|
||||||
<% if (production) { %>
|
<% if (production) { %>
|
||||||
<link rel="stylesheet" type="text/css" href="resources/ws.min.css?_=<%=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/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="resources/ws.min.js?_=<%=production%>"></script>
|
||||||
<script type="text/javascript" src="scripts/custom.js?_=<%=production%>"></script>
|
<script type="text/javascript" src="scripts/custom.js?_=<%=production%>"></script>
|
||||||
<% } else { %>
|
<% } else { %>
|
||||||
|
@ -27,25 +28,20 @@
|
||||||
<script type="text/javascript" src="scripts/vendor/jquery.autocomplete.min.js"></script>
|
<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/nosleep.js"></script>
|
||||||
<script type="text/javascript" src="scripts/vendor/auto/swiped-events.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>
|
<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/currentweather.mjs"></script>
|
||||||
<script type="module" src="scripts/modules/almanac.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/icons.mjs"></script>
|
||||||
<script type="module" src="scripts/modules/extendedforecast.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/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/latestobservations.mjs"></script>
|
||||||
<script type="module" src="scripts/modules/localforecast.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/radar.mjs"></script>
|
||||||
<script type="module" src="scripts/modules/regionalforecast.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/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>
|
||||||
<script type="module" src="scripts/index.mjs"></script>
|
|
||||||
|
|
||||||
<!-- data -->
|
<!-- data -->
|
||||||
<script type="text/javascript" src="scripts/data/states.js"></script>
|
<script type="text/javascript" src="scripts/data/states.js"></script>
|
||||||
|
@ -53,8 +49,7 @@
|
||||||
<script type="text/javascript" src="scripts/data/regionalcities.js"></script>
|
<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/data/stations.js"></script>
|
||||||
|
|
||||||
<script type="text/javascript" src="scripts/vendor/auto/suncalc.js"></script>
|
<script type="text/javascript" src="scripts/custom.js"></script>
|
||||||
<script type="text/javascript" src="scripts/custom.js?_=<%=production%>"></script>
|
|
||||||
|
|
||||||
<% } %>
|
<% } %>
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue