@polylith/builder 0.2.19 → 0.2.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/App.js +27 -7
- package/package.json +3 -2
package/App.js
CHANGED
|
@@ -19,7 +19,7 @@ import resources from "./plugin-copy-resources.js";
|
|
|
19
19
|
import jsconfig from "./plugin-jsconfig.js";
|
|
20
20
|
import loadConfigs from "./plugin-config.js";
|
|
21
21
|
import watchLog from "./plugin-watch.js";
|
|
22
|
-
|
|
22
|
+
import { terser } from "rollup-plugin-terser";
|
|
23
23
|
import {forceToPosix, fileExists} from './utils.js'
|
|
24
24
|
import ConfigFeature from './ConfigFeature.js';
|
|
25
25
|
import Files from './Files.js';
|
|
@@ -204,6 +204,23 @@ export default class App {
|
|
|
204
204
|
return './' + path;
|
|
205
205
|
}
|
|
206
206
|
|
|
207
|
+
/**
|
|
208
|
+
* Call this method with to set specific options for live reload
|
|
209
|
+
*
|
|
210
|
+
* @param {Object} on set to true to turn on destination watching
|
|
211
|
+
* @property {Number} port set this to a port for as livereload port,
|
|
212
|
+
* defaults to 35800
|
|
213
|
+
* @property {("http"|"https")} protocol the protocol to use for the
|
|
214
|
+
* livereload websocket. default to 'http'
|
|
215
|
+
* @property hostname the hostname for the livereload websocket. defaults to
|
|
216
|
+
* 'localhost;
|
|
217
|
+
* @property {Object} https if this has a value, it will be set as the http
|
|
218
|
+
* value in the livereload options
|
|
219
|
+
*/
|
|
220
|
+
setLiveReloadOptions(options) {
|
|
221
|
+
this.liveReloadOptions = options;
|
|
222
|
+
}
|
|
223
|
+
|
|
207
224
|
/**
|
|
208
225
|
* Call this method with true to reload the browser when any files in the
|
|
209
226
|
* destination folder have changed.
|
|
@@ -573,7 +590,7 @@ export default class App {
|
|
|
573
590
|
await this.findMainCss();
|
|
574
591
|
|
|
575
592
|
this.cssFiles.forEach(function(uri) {
|
|
576
|
-
cssTags += ` <link rel="stylesheet" href="${uri}"></link
|
|
593
|
+
cssTags += ` <link rel="stylesheet" href="${uri}"></link>\n`
|
|
577
594
|
}, this);
|
|
578
595
|
|
|
579
596
|
return cssTags;
|
|
@@ -669,6 +686,7 @@ export default class App {
|
|
|
669
686
|
|
|
670
687
|
async generateBuildConfiguration() {
|
|
671
688
|
var input = [this.fullIndexPath];
|
|
689
|
+
var env = process.env.NODE_ENV || 'dev';
|
|
672
690
|
|
|
673
691
|
// using a for loop because we are making an async call
|
|
674
692
|
for (let loadable of this.loadables) {
|
|
@@ -716,16 +734,18 @@ export default class App {
|
|
|
716
734
|
watchLog(),
|
|
717
735
|
];
|
|
718
736
|
|
|
737
|
+
if (env !== 'dev') plugins.push(terser());
|
|
738
|
+
|
|
719
739
|
if (this.liveReload) {
|
|
720
740
|
let plugin;
|
|
721
741
|
|
|
722
742
|
// rollup-plugin-livereload always bases the protocol on the
|
|
723
743
|
// webpage url. This is bad, here we override it
|
|
724
|
-
if (
|
|
725
|
-
let port = this.
|
|
726
|
-
let protocol = this.
|
|
727
|
-
let hostname =
|
|
728
|
-
let https =
|
|
744
|
+
if (this.liveReloadOptions) {
|
|
745
|
+
let port = this.liveReloadOptions.port || 35800;
|
|
746
|
+
let protocol = this.liveReloadOptions.protocol || 'http';
|
|
747
|
+
let hostname = this.liveReloadOptions.hostname || 'localhost';
|
|
748
|
+
let https = this.liveReloadOptions.https || null;
|
|
729
749
|
let url = `${protocol}://${hostname}:${port}/livereload.js?snipver=1&port=${port}`;
|
|
730
750
|
|
|
731
751
|
plugin = livereload({watch: this.destPath, https: https, clientUrl: url, port: port})
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@polylith/builder",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.21",
|
|
4
4
|
"description": "The polylith builder",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -19,8 +19,8 @@
|
|
|
19
19
|
"@babel/preset-env": "^7.16.11",
|
|
20
20
|
"@babel/preset-react": "^7.16.7",
|
|
21
21
|
"@ondohers/console-colors": "^0.1.1",
|
|
22
|
-
"@polylith/core": "^0.1.9",
|
|
23
22
|
"@polylith/config-store": "0.1.2",
|
|
23
|
+
"@polylith/core": "^0.1.9",
|
|
24
24
|
"@rollup/plugin-babel": "^5.3.0",
|
|
25
25
|
"@rollup/plugin-commonjs": "^24.0.0",
|
|
26
26
|
"@rollup/plugin-json": "^5.0.2",
|
|
@@ -38,6 +38,7 @@
|
|
|
38
38
|
"rollup-plugin-livereload": "^2.0.5",
|
|
39
39
|
"rollup-plugin-polyfill-node": "^0.11.0",
|
|
40
40
|
"rollup-plugin-styles": "^4.0.0",
|
|
41
|
+
"rollup-plugin-terser": "^7.0.2",
|
|
41
42
|
"sass": "^1.43.4"
|
|
42
43
|
}
|
|
43
44
|
}
|