wirejs-scripts 1.0.3 → 2.0.0

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/bin.js CHANGED
@@ -1,114 +1,112 @@
1
1
  #!/usr/bin/env node
2
-
3
- const process = require('process');
4
- const child_process = require('child_process');
5
- const rimraf = require('rimraf');
6
- const fs = require('fs');
7
- const path = require('path');
8
-
9
- const exgratia = require('ex-gratia');
10
- const webpack = require('webpack');
11
- const webpackConfigure = require('./configs/webpack.config');
12
- const WebpackDevServer = require('webpack-dev-server');
13
-
14
- const CWD = process.cwd();
15
- const webpackConfig = webpackConfigure(process.env, process.argv);
16
- const [nodeBinPath, scriptPath, action] = process.argv;
17
- const processes = [];
18
-
19
- async function exec(cmd) {
20
- console.log('exec', cmd);
21
- return new Promise((resolve, reject) => {
22
- let proc;
23
- proc = child_process.exec(cmd, (error, stdout, stderr) => {
24
- processes.splice(processes.indexOf(proc), 1);
25
- if (error || stderr) {
26
- reject({ error, stderr });
27
- } else {
28
- resolve(stdout);
29
- }
30
- });
31
- processes.push(proc);
32
- });
33
- }
34
-
35
- async function compile(watch = false) {
36
- const stats = await new Promise((resolve, reject) => {
37
- if (watch) {
38
- compiler = webpack({
39
- ...webpackConfig,
40
- mode: 'development'
41
- });
42
-
43
- const server = new WebpackDevServer({
44
- static: {
45
- directory: path.join(CWD, 'dist')
46
- },
47
- open: true,
48
- port: 9999,
49
- }, compiler);
50
-
51
- console.log('Starting server...');
52
- server.start().then(() => {
53
- resolve({});
54
- });
55
-
56
- resolve({});
57
- } else {
58
- compiler = webpack(webpackConfig);
59
- compiler.run((err, res) => {
60
- if (err) {
61
- reject(err);
62
- } else {
63
- resolve(res);
64
- }
65
- });
66
- }
67
- });
68
-
69
- if (stats?.compilation?.errors?.length > 0) {
70
- console.log(stats.compilation.errors);
71
- throw new Error('Build failed.');
72
- }
73
-
74
- return stats;
75
- }
76
-
77
- const engine = {
78
- async build({ watch = false } = {}) {
79
- rimraf.sync('dist');
80
- fs.mkdirSync('dist');
81
- try {
82
- await compile(watch);
83
- } catch (err) {
84
- console.log(err);
85
- }
86
- },
87
-
88
- async start() {
89
- this.build({ watch: true });
90
-
91
- await new Promise(resolve => {
92
- function exitGracefully() {
93
- console.log('Exiting gracefully ...');
94
- processes.forEach(p => p.kill());
95
- resolve();
96
- }
97
- process.on('SIGINT', exitGracefully);
98
- process.on('SIGTERM', exitGracefully);
99
- });
100
-
101
- // explicit exit forces lingering child processes to die.
102
- process.exit();
103
- }
104
-
105
- };
106
-
107
- if (typeof engine[action] === 'function') {
108
- console.log(`Running ${action} ... `);
109
- engine[action]().then(() => {
110
- console.log('All done!');
111
- });
112
- } else {
113
- console.error(`Invalid wirejs-scripts action: ${action}`);
114
- }
2
+
3
+ const process = require('process');
4
+ const child_process = require('child_process');
5
+ const rimraf = require('rimraf');
6
+ const fs = require('fs');
7
+ const path = require('path');
8
+
9
+ const webpack = require('webpack');
10
+ const webpackConfigure = require('./configs/webpack.config');
11
+ const WebpackDevServer = require('webpack-dev-server');
12
+
13
+ const CWD = process.cwd();
14
+ const webpackConfig = webpackConfigure(process.env, process.argv);
15
+ const [nodeBinPath, scriptPath, action] = process.argv;
16
+ const processes = [];
17
+
18
+ async function exec(cmd) {
19
+ console.log('exec', cmd);
20
+ return new Promise((resolve, reject) => {
21
+ let proc;
22
+ proc = child_process.exec(cmd, (error, stdout, stderr) => {
23
+ processes.splice(processes.indexOf(proc), 1);
24
+ if (error || stderr) {
25
+ reject({ error, stderr });
26
+ } else {
27
+ resolve(stdout);
28
+ }
29
+ });
30
+ processes.push(proc);
31
+ });
32
+ }
33
+
34
+ async function compile(watch = false) {
35
+ const stats = await new Promise((resolve, reject) => {
36
+ if (watch) {
37
+ compiler = webpack({
38
+ ...webpackConfig,
39
+ mode: 'development'
40
+ });
41
+
42
+ const server = new WebpackDevServer({
43
+ static: {
44
+ directory: path.join(CWD, 'dist')
45
+ },
46
+ open: true,
47
+ }, compiler);
48
+
49
+ console.log('Starting server...');
50
+ server.start().then(() => {
51
+ resolve({});
52
+ });
53
+
54
+ resolve({});
55
+ } else {
56
+ compiler = webpack(webpackConfig);
57
+ compiler.run((err, res) => {
58
+ if (err) {
59
+ reject(err);
60
+ } else {
61
+ resolve(res);
62
+ }
63
+ });
64
+ }
65
+ });
66
+
67
+ if (stats?.compilation?.errors?.length > 0) {
68
+ console.log(stats.compilation.errors);
69
+ throw new Error('Build failed.');
70
+ }
71
+
72
+ return stats;
73
+ }
74
+
75
+ const engine = {
76
+ async build({ watch = false } = {}) {
77
+ rimraf.sync('dist');
78
+ fs.mkdirSync('dist');
79
+ try {
80
+ await compile(watch);
81
+ } catch (err) {
82
+ console.log(err);
83
+ }
84
+ },
85
+
86
+ async start() {
87
+ this.build({ watch: true });
88
+
89
+ await new Promise(resolve => {
90
+ function exitGracefully() {
91
+ console.log('Exiting gracefully ...');
92
+ processes.forEach(p => p.kill());
93
+ resolve();
94
+ }
95
+ process.on('SIGINT', exitGracefully);
96
+ process.on('SIGTERM', exitGracefully);
97
+ });
98
+
99
+ // explicit exit forces lingering child processes to die.
100
+ process.exit();
101
+ }
102
+
103
+ };
104
+
105
+ if (typeof engine[action] === 'function') {
106
+ console.log(`Running ${action} ... `);
107
+ engine[action]().then(() => {
108
+ console.log('All done!');
109
+ });
110
+ } else {
111
+ console.error(`Invalid wirejs-scripts action: ${action}`);
112
+ }
@@ -1,349 +1,295 @@
1
- const fs = require('fs');
2
- const path = require('path');
3
- const glob = require('glob');
4
- const { exec } = require('child_process');
5
- const process = require('process');
6
- const CopyWebpackPlugin = require('copy-webpack-plugin');
7
- const marked = require('marked');
8
- const { JSDOM } = require('jsdom');
9
-
10
- const CWD = process.cwd();
11
-
12
- // https://marked.js.org/using_advanced
13
- marked.setOptions({
14
- highlight: function (code, lang) {
15
- try {
16
- const highlighter = require('highlight.js');
17
- const language = highlighter.getLanguage(lang) ? lang : 'plaintext';
18
- return highlighter.highlight(code, { language }).value;
19
- } catch (e) {
20
- console.log("highlight.js not installed. Skipping syntax highlighting.");
21
- }
22
- }
23
- });
24
-
25
- const BUILD_ID = (new Date()).getTime();
26
-
27
- fs.writeFileSync('./src/build_id.json', JSON.stringify(BUILD_ID.toString()));
28
-
29
-
30
- // TODO: Refactor these transforms out of here.
31
- // TODO: Create a separate package to manage all of this for easy reuse on
32
- // other projects.
33
- // TODO: consider whether using the front-end framework for SSG would be safe,
34
- // and intuitive, rather than having two completely separate rendering modes.
35
-
36
- function distPath({ subpathOut = '', subpathIn = '' } = {}) {
37
- return function ({ context, absoluteFilename }) {
38
- const prefixIn = path.resolve(context, subpathIn);
39
- const prefixOut = path.resolve(context, 'dist', subpathOut);
40
- const relativeName = path.join('./', absoluteFilename.slice(prefixIn.toString().length));
41
- const fullOutPath = path.resolve(prefixOut, relativeName)
42
- .replace(/\.md$/, ".html");
43
- console.log(`Mapping ${relativeName} to ${fullOutPath}`);
44
- return fullOutPath;
45
- };
46
- };
47
-
48
- const layouts = {};
49
- const CollectLayouts = {
50
- transformer: (content, path) => {
51
- // add one to dirname prefix to include separating slash
52
- const relativePath = path.slice(CWD.length + 1);
53
- layouts[relativePath] = content.toString();
54
- return layouts[relativePath];
55
- }
56
- };
57
-
58
- async function mermaid(text) {
59
- const tempbase = path.join(
60
- __dirname,
61
- `__mermaid_temp_${new Date().getTime()}`
62
- );
63
- const tempInput = `${tempbase}.txt`;
64
- const tempOutput = `${tempbase}.svg`;
65
- const pConfigPath = path.join(
66
- __dirname,
67
- 'puppeteer-config.json'
68
- );
69
-
70
- console.log(`writing ${tempInput} ...`);
71
- fs.writeFileSync(tempInput, text);
72
-
73
- await new Promise((resolve, reject) => {
74
- const cmd = `npm exec mmdc -- -i "${tempInput}" -o "${tempOutput}" -b transparent -p "${pConfigPath}"`;
75
- console.log(`executing ${cmd} ...`);
76
- exec(cmd, {cwd: __dirname}, (err, stdout, stderr) => {
77
- if (err || stderr) {
78
- console.log('failed', {err, stdout, stderr});
79
- reject(err);
80
- } else {
81
- console.log('succeeded', stdout);
82
- resolve();
83
- }
84
- });
85
- });
86
- console.log(`mermaid CLI done generating ${tempOutput}`);
87
-
88
- const svg = fs.readFileSync(tempOutput);
89
- fs.unlinkSync(tempInput)
90
- fs.unlinkSync(tempOutput);
91
-
92
- return svg;
93
- };
94
-
95
- const SSG = {
96
- transformer: async (content, _path) => {
97
- let _meta = {};
98
- function meta(o) {
99
- _meta = o;
100
- return '';
101
- }
102
-
103
- let body;
104
- try {
105
- if (_path.endsWith('.md')) {
106
- let isInCodeBlock = false;
107
- const escapedMarkdown = content.toString().split(/\n/)
108
- .reduce((lines, line) => {
109
- if (isInCodeBlock) {
110
- lines[lines.length - 1] += "\n" + line;
111
- } else {
112
- lines.push(line);
113
- }
114
- if (line.startsWith('```')) {
115
- isInCodeBlock = !isInCodeBlock;
116
- }
117
- return lines;
118
- }, [])
119
- .map(l => l.trim()).join('\n')
120
- .replace(/(``+)/g, m => Array(m.length).fill('\\`').join(''))
121
- ;
122
- const bodyMarkdown = eval('`' + escapedMarkdown + '`');
123
- const prebody = marked(bodyMarkdown);
124
- const { window } = new JSDOM(prebody, { querySelectorAll: true });
125
-
126
- if (window && window.document && window.document.body) {
127
- await Promise.all(
128
- [...window.document.body
129
- .querySelectorAll('.language-mermaid')
130
- ].map(async mdNode => {
131
- const svg = await mermaid(mdNode.textContent);
132
- mdNode.parentNode.innerHTML = svg;
133
- })
134
- );
135
- body = window.document.body.innerHTML;
136
- } else {
137
- body = prebody;
138
- }
139
-
140
- } else {
141
- body = eval('`' + content + '`');
142
- }
143
- } catch (err) {
144
- console.error(`Could not parse page ${_path}`, err);
145
- throw err;
146
- }
147
-
148
- const metatags = Object.entries(_meta).map(([tag, content]) => {
149
- tag = tag.replace(/"/g, '"');
150
- content = content.replace(/"/g, '"');
151
- return `<meta name="${tag}" content="${content}" />`;
152
- }).join('\n');
153
-
154
- let title = _meta.title;
155
-
156
- // apply no layout if the document has already provided the
157
- // overarching html structure.
158
- if (!_meta.layout && body && (
159
- String(body).startsWith('<!doctype html>')
160
- || String(body).startsWith('<html'))
161
- ) {
162
- return body;
163
- }
164
-
165
- const layoutPath = path.join(
166
- 'src',
167
- 'layouts',
168
- (_meta.layout || 'default')
169
- ) + '.html';
170
-
171
- const layout = layouts[layoutPath];
172
-
173
- try {
174
- return eval('`' + layout + '`');
175
- } catch (err) {
176
- console.error(`Could not parse layout ${layoutPath}`, err);
177
- throw err;
178
- }
179
- }
180
- };
181
-
182
- module.exports = (env, argv) => {
183
- var devtool = 'source-map';
184
- if (argv.mode == 'development') {
185
- devtool = 'eval-cheap-source-map';
186
- }
187
-
188
- const sources = ['./src/index.js']
189
- .concat(glob.sync('./src/layouts/**/*.js'))
190
- .concat(glob.sync('./src/routes/**/*.js'))
191
- ;
192
-
193
- const entry = sources.reduce((files, path) => {
194
- if (path.match(/src\/routes/)) {
195
- files[path.toString().slice('./src/routes'.length)] = path;
196
- } else if (path.match(/src\/layouts/)) {
197
- files[path.toString().slice('./src/'.length)] = path;
198
- }
199
- return files;
200
- }, {});
201
-
202
- return {
203
- /*
204
- devServer: {
205
- contentBase: path.join(CWD, 'dist'),
206
- compress: true,
207
- open: true,
208
- port: 9999,
209
- watchContentBase: true,
210
- // liveReload: true,
211
- // hot: true
212
- },
213
- */
214
- watchOptions: {
215
- ignored: [
216
- "**/dist/*",
217
- "**/node_modules/*"
218
- ]
219
- },
220
- node: {
221
- __filename: true
222
- },
223
- entry,
224
- output: {
225
- filename: "[name]"
226
- },
227
- devtool,
228
- plugins: [
229
-
230
- // TODO: does it make sense to actually handle static assets
231
- // first? then layouts? then everything else?
232
-
233
- // handle layouts first. other things depend on them.
234
- new CopyWebpackPlugin({
235
- patterns: [
236
- {
237
- from: './src/layouts/**/*.html',
238
- to: distPath({
239
- subpathIn: 'src/layouts',
240
- subpathOut: 'layouts'
241
- }),
242
- transform: CollectLayouts,
243
- noErrorOnMissing: true,
244
- },
245
- ]
246
- }),
247
-
248
- // now pages, etc.
249
- new CopyWebpackPlugin({
250
- patterns: [
251
- {
252
- from: 'static',
253
- noErrorOnMissing: true,
254
- priority: 10,
255
- },
256
- {
257
- from: './src/routes/**/*.md',
258
- to: distPath({ subpathIn: 'src/routes' }),
259
- transform: SSG,
260
- noErrorOnMissing: true,
261
- priority: 3,
262
- },
263
- {
264
- from: './src/routes/**/*.html',
265
- to: distPath({ subpathIn: 'src/routes' }),
266
- transform: SSG,
267
- noErrorOnMissing: true,
268
- priority: 3,
269
- },
270
- {
271
- from: './src/routes/**/*.css',
272
- to: distPath({ subpathIn: 'src/routes' }),
273
- noErrorOnMissing: true,
274
- // trasform: ???
275
- priority: 3,
276
- },
277
- {
278
- from: './src/routes/**/*.png',
279
- to: distPath({ subpathIn: 'src/routes' }),
280
- noErrorOnMissing: true,
281
- priority: 3,
282
- },
283
- {
284
- from: './src/routes/**/*.jpg',
285
- to: distPath({ subpathIn: 'src/routes' }),
286
- noErrorOnMissing: true,
287
- priority: 3,
288
- },
289
- {
290
- from: './src/routes/**/*.json',
291
- to: distPath({ subpathIn: 'src/routes' }),
292
- noErrorOnMissing: true,
293
- priority: 3,
294
- },
295
- {
296
- from: './src/routes/**/*.svg',
297
- to: distPath({ subpathIn: 'src/routes' }),
298
- noErrorOnMissing: true,
299
- priority: 3,
300
- },
301
- {
302
- from: './src/routes/**/*.mp3',
303
- to: distPath({ subpathIn: 'src/routes' }),
304
- noErrorOnMissing: true,
305
- priority: 3,
306
- },
307
- ],
308
- })
309
- ],
310
- module: {
311
- rules: [
312
- {
313
- test: /\.css$/,
314
- use: [
315
- "style-loader",
316
- // path.resolve(__dirname, '../node_modules/style-loader'),
317
- {
318
- loader: "css-loader",
319
- // loader: path.resolve(__dirname, '../node_modules/css-loader'),
320
- options: {
321
- // don't try to require() url assets
322
- url: false
323
- }
324
- }
325
- ]
326
- },
327
- {
328
- test: /\.html$/,
329
- loader: "file-loader",
330
- // loader: path.resolve(__dirname, '../node_modules/file-loader'),
331
- options: {
332
- name: "[name].[ext]",
333
- }
334
- },
335
- {
336
- test: /\.mjs$/,
337
- resolve: {
338
- fullySpecified: false
339
- }
340
- },
341
- {
342
- test: /\.tpl$/,
343
- use: "raw-loader",
344
- // use: path.resolve(__dirname, '../node_modules/raw-loader')
345
- },
346
- ]
347
- }
348
- };
349
- };
1
+ const fs = require('fs');
2
+ const path = require('path');
3
+ const glob = require('glob');
4
+ const { exec } = require('child_process');
5
+ const process = require('process');
6
+ const CopyWebpackPlugin = require('copy-webpack-plugin');
7
+ const marked = require('marked');
8
+
9
+ const CWD = process.cwd();
10
+
11
+ // https://marked.js.org/using_advanced
12
+ marked.setOptions({
13
+ highlight: function (code, lang) {
14
+ try {
15
+ const highlighter = require('highlight.js');
16
+ const language = highlighter.getLanguage(lang) ? lang : 'plaintext';
17
+ return highlighter.highlight(code, { language }).value;
18
+ } catch (e) {
19
+ console.log("highlight.js not installed. Skipping syntax highlighting.");
20
+ }
21
+ }
22
+ });
23
+
24
+ const BUILD_ID = (new Date()).getTime();
25
+
26
+ fs.writeFileSync('./src/build_id.json', JSON.stringify(BUILD_ID.toString()));
27
+
28
+
29
+ // TODO: Refactor these transforms out of here.
30
+ // TODO: Create a separate package to manage all of this for easy reuse on
31
+ // other projects.
32
+ // TODO: consider whether using the front-end framework for SSG would be safe,
33
+ // and intuitive, rather than having two completely separate rendering modes.
34
+
35
+ function distPath({ subpathOut = '', subpathIn = '' } = {}) {
36
+ return function ({ context, absoluteFilename }) {
37
+ const prefixIn = path.resolve(context, subpathIn);
38
+ const prefixOut = path.resolve(context, 'dist', subpathOut);
39
+ const relativeName = path.join('./', absoluteFilename.slice(prefixIn.toString().length));
40
+ const fullOutPath = path.resolve(prefixOut, relativeName)
41
+ .replace(/\.md$/, ".html");
42
+ console.log(`Mapping ${relativeName} to ${fullOutPath}`);
43
+ return fullOutPath;
44
+ };
45
+ };
46
+
47
+ const layouts = {};
48
+ const CollectLayouts = {
49
+ transformer: (content, path) => {
50
+ // add one to dirname prefix to include separating slash
51
+ const relativePath = path.slice(CWD.length + 1);
52
+ layouts[relativePath] = content.toString();
53
+ return layouts[relativePath];
54
+ }
55
+ };
56
+
57
+ const SSG = {
58
+ transformer: async (content, _path) => {
59
+ let _meta = {};
60
+ function meta(o) {
61
+ _meta = o;
62
+ return '';
63
+ }
64
+
65
+ let body;
66
+ try {
67
+ if (_path.endsWith('.md')) {
68
+ let isInCodeBlock = false;
69
+ const escapedMarkdown = content.toString().split(/\n/)
70
+ .reduce((lines, line) => {
71
+ if (isInCodeBlock) {
72
+ lines[lines.length - 1] += "\n" + line;
73
+ } else {
74
+ lines.push(line);
75
+ }
76
+ if (line.startsWith('```')) {
77
+ isInCodeBlock = !isInCodeBlock;
78
+ }
79
+ return lines;
80
+ }, [])
81
+ .map(l => l.trim()).join('\n')
82
+ .replace(/(``+)/g, m => Array(m.length).fill('\\`').join(''))
83
+ ;
84
+ const bodyMarkdown = eval('`' + escapedMarkdown + '`');
85
+ body = marked(bodyMarkdown);
86
+ } else {
87
+ body = eval('`' + content + '`');
88
+ }
89
+ } catch (err) {
90
+ console.error(`Could not parse page ${_path}`, err);
91
+ throw err;
92
+ }
93
+
94
+ const metatags = Object.entries(_meta).map(([tag, content]) => {
95
+ tag = tag.replace(/"/g, '&quot;');
96
+ content = content.replace(/"/g, '&quot;');
97
+ return `<meta name="${tag}" content="${content}" />`;
98
+ }).join('\n');
99
+
100
+ let title = _meta.title;
101
+
102
+ // apply no layout if the document has already provided the
103
+ // overarching html structure.
104
+ if (!_meta.layout && body && (
105
+ String(body).startsWith('<!doctype html>')
106
+ || String(body).startsWith('<html'))
107
+ ) {
108
+ return body;
109
+ }
110
+
111
+ const layoutPath = path.join(
112
+ 'src',
113
+ 'layouts',
114
+ (_meta.layout || 'default')
115
+ ) + '.html';
116
+
117
+ const layout = layouts[layoutPath];
118
+
119
+ try {
120
+ return eval('`' + layout + '`');
121
+ } catch (err) {
122
+ console.error(`Could not parse layout ${layoutPath}`, err);
123
+ throw err;
124
+ }
125
+ }
126
+ };
127
+
128
+ module.exports = (env, argv) => {
129
+ var devtool = 'source-map';
130
+ if (argv.mode == 'development') {
131
+ devtool = 'eval-cheap-source-map';
132
+ }
133
+
134
+ const sources = ['./src/index.js']
135
+ .concat(glob.sync('./src/layouts/**/*.js'))
136
+ .concat(glob.sync('./src/routes/**/*.js'))
137
+ ;
138
+
139
+ const entry = sources.reduce((files, path) => {
140
+ if (path.match(/src\/routes/)) {
141
+ files[path.toString().slice('./src/routes'.length)] = path;
142
+ } else if (path.match(/src\/layouts/)) {
143
+ files[path.toString().slice('./src/'.length)] = path;
144
+ }
145
+ return files;
146
+ }, {});
147
+
148
+ return {
149
+ /*
150
+ devServer: {
151
+ contentBase: path.join(CWD, 'dist'),
152
+ compress: true,
153
+ open: true,
154
+ port: 9999,
155
+ watchContentBase: true,
156
+ // liveReload: true,
157
+ // hot: true
158
+ },
159
+ */
160
+ watchOptions: {
161
+ ignored: [
162
+ "**/dist/*",
163
+ "**/node_modules/*"
164
+ ]
165
+ },
166
+ node: {
167
+ __filename: true
168
+ },
169
+ entry,
170
+ output: {
171
+ filename: "[name]"
172
+ },
173
+ devtool,
174
+ plugins: [
175
+
176
+ // TODO: does it make sense to actually handle static assets
177
+ // first? then layouts? then everything else?
178
+
179
+ // handle layouts first. other things depend on them.
180
+ new CopyWebpackPlugin({
181
+ patterns: [
182
+ {
183
+ from: './src/layouts/**/*.html',
184
+ to: distPath({
185
+ subpathIn: 'src/layouts',
186
+ subpathOut: 'layouts'
187
+ }),
188
+ transform: CollectLayouts,
189
+ noErrorOnMissing: true,
190
+ },
191
+ ]
192
+ }),
193
+
194
+ // now pages, etc.
195
+ new CopyWebpackPlugin({
196
+ patterns: [
197
+ {
198
+ from: 'static',
199
+ noErrorOnMissing: true,
200
+ priority: 10,
201
+ },
202
+ {
203
+ from: './src/routes/**/*.md',
204
+ to: distPath({ subpathIn: 'src/routes' }),
205
+ transform: SSG,
206
+ noErrorOnMissing: true,
207
+ priority: 3,
208
+ },
209
+ {
210
+ from: './src/routes/**/*.html',
211
+ to: distPath({ subpathIn: 'src/routes' }),
212
+ transform: SSG,
213
+ noErrorOnMissing: true,
214
+ priority: 3,
215
+ },
216
+ {
217
+ from: './src/routes/**/*.css',
218
+ to: distPath({ subpathIn: 'src/routes' }),
219
+ noErrorOnMissing: true,
220
+ // trasform: ???
221
+ priority: 3,
222
+ },
223
+ {
224
+ from: './src/routes/**/*.png',
225
+ to: distPath({ subpathIn: 'src/routes' }),
226
+ noErrorOnMissing: true,
227
+ priority: 3,
228
+ },
229
+ {
230
+ from: './src/routes/**/*.jpg',
231
+ to: distPath({ subpathIn: 'src/routes' }),
232
+ noErrorOnMissing: true,
233
+ priority: 3,
234
+ },
235
+ {
236
+ from: './src/routes/**/*.json',
237
+ to: distPath({ subpathIn: 'src/routes' }),
238
+ noErrorOnMissing: true,
239
+ priority: 3,
240
+ },
241
+ {
242
+ from: './src/routes/**/*.svg',
243
+ to: distPath({ subpathIn: 'src/routes' }),
244
+ noErrorOnMissing: true,
245
+ priority: 3,
246
+ },
247
+ {
248
+ from: './src/routes/**/*.mp3',
249
+ to: distPath({ subpathIn: 'src/routes' }),
250
+ noErrorOnMissing: true,
251
+ priority: 3,
252
+ },
253
+ ],
254
+ })
255
+ ],
256
+ module: {
257
+ rules: [
258
+ {
259
+ test: /\.css$/,
260
+ use: [
261
+ "style-loader",
262
+ // path.resolve(__dirname, '../node_modules/style-loader'),
263
+ {
264
+ loader: "css-loader",
265
+ // loader: path.resolve(__dirname, '../node_modules/css-loader'),
266
+ options: {
267
+ // don't try to require() url assets
268
+ url: false
269
+ }
270
+ }
271
+ ]
272
+ },
273
+ {
274
+ test: /\.html$/,
275
+ loader: "file-loader",
276
+ // loader: path.resolve(__dirname, '../node_modules/file-loader'),
277
+ options: {
278
+ name: "[name].[ext]",
279
+ }
280
+ },
281
+ {
282
+ test: /\.mjs$/,
283
+ resolve: {
284
+ fullySpecified: false
285
+ }
286
+ },
287
+ {
288
+ test: /\.tpl$/,
289
+ use: "raw-loader",
290
+ // use: path.resolve(__dirname, '../node_modules/raw-loader')
291
+ },
292
+ ]
293
+ }
294
+ };
295
+ };
package/package.json CHANGED
@@ -1,36 +1,33 @@
1
- {
2
- "name": "wirejs-scripts",
3
- "version": "1.0.3",
4
- "description": "Basic build and start commands for wirejs apps",
5
- "bin": {
6
- "wirejs-scripts": "./bin.js"
7
- },
8
- "repository": {
9
- "type": "git",
10
- "url": "git+https://github.com/svidgen/wirejs-scripts.git"
11
- },
12
- "author": "Jon Wire",
13
- "license": "AGPL-3.0-only",
14
- "bugs": {
15
- "url": "https://github.com/svidgen/wirejs-scripts/issues"
16
- },
17
- "homepage": "https://github.com/svidgen/wirejs-scripts#readme",
18
- "dependencies": {
19
- "@mermaid-js/mermaid-cli": "^9.0.0",
20
- "copy-webpack-plugin": "^10.2.4",
21
- "css-loader": "^5.2.0",
22
- "file-loader": "^6.2.0",
23
- "glob": "^7.2.0",
24
- "jsdom": "^16.5.2",
25
- "marked": "^2.0.1",
26
- "raw-loader": "^4.0.2",
27
- "rimraf": "^3.0.2",
28
- "style-loader": "^2.0.0",
29
- "webpack": "^5.28.0",
30
- "webpack-cli": "^4.6.0",
31
- "webpack-dev-server": "^4.8.1",
32
- "ex-gratia": "^1.0.3",
33
- "highlight.js": "^11.1.0",
34
- "wirejs-dom": "^1.0.4"
35
- }
36
- }
1
+ {
2
+ "name": "wirejs-scripts",
3
+ "version": "2.0.0",
4
+ "description": "Basic build and start commands for wirejs apps",
5
+ "bin": {
6
+ "wirejs-scripts": "./bin.js"
7
+ },
8
+ "repository": {
9
+ "type": "git",
10
+ "url": "git+https://github.com/svidgen/wirejs-scripts.git"
11
+ },
12
+ "author": "Jon Wire",
13
+ "license": "AGPL-3.0-only",
14
+ "bugs": {
15
+ "url": "https://github.com/svidgen/wirejs-scripts/issues"
16
+ },
17
+ "homepage": "https://github.com/svidgen/wirejs-scripts#readme",
18
+ "dependencies": {
19
+ "copy-webpack-plugin": "^10.2.4",
20
+ "css-loader": "^5.2.0",
21
+ "file-loader": "^6.2.0",
22
+ "glob": "^7.2.0",
23
+ "marked": "^2.0.1",
24
+ "raw-loader": "^4.0.2",
25
+ "rimraf": "^3.0.2",
26
+ "style-loader": "^2.0.0",
27
+ "webpack": "^5.28.0",
28
+ "webpack-cli": "^4.6.0",
29
+ "webpack-dev-server": "^4.8.1",
30
+ "highlight.js": "^11.1.0",
31
+ "wirejs-dom": "^1.0.4"
32
+ }
33
+ }
@@ -1,3 +0,0 @@
1
- {
2
- "args": ["--no-sandbox"]
3
- }