@caweb/webpack 1.6.6 → 1.6.8

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/lib/args.js CHANGED
@@ -25,9 +25,15 @@ let { values: flags } = parseArgs( {
25
25
  allowPositionals: true,
26
26
  allowNegative: true,
27
27
 
28
- // in order for the flags to work in the cli's afterStart hook,
29
- // we need to set the options that are used in the start command
28
+ // in order for the flags to work with the cli's params,
29
+ // we need to set the options
30
30
  options: {
31
+ template: {
32
+ type: 'string',
33
+ },
34
+ scheme: {
35
+ type: 'string',
36
+ },
31
37
  cwd: {
32
38
  type: 'string',
33
39
  },
package/lib/server.js CHANGED
@@ -98,6 +98,7 @@ let devServer = {
98
98
  hot: true,
99
99
 
100
100
  historyApiFallback: {
101
+ index: '/404.html',
101
102
  rewrites: [
102
103
  // Rewrite any request that doesn't have a file extension to your 404 page
103
104
  // This is a simple regex; adjust as needed
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@caweb/webpack",
3
- "version": "1.6.6",
3
+ "version": "1.6.8",
4
4
  "description": "CAWebPublishing Webpack Configuration",
5
5
  "main": "webpack.config.js",
6
6
  "files": [
@@ -47,7 +47,7 @@
47
47
  "html-webpack-skip-assets-plugin": "^1.0.4",
48
48
  "thread-loader": "^4.0.4",
49
49
  "ts-loader": "^9.5.4",
50
- "webpack": "^5.105.1",
50
+ "webpack": "^5.105.2",
51
51
  "webpack-cli": "^6.0.1",
52
52
  "webpack-dev-server": "^5.2.3",
53
53
  "webpack-merge": "^6.0.1",
@@ -15,7 +15,7 @@ import Handlebars from 'handlebars';
15
15
  /**
16
16
  * Internal Dependencies
17
17
  */
18
- import { getArgVal } from '../lib/args.js';
18
+ import { getArgVal, flags } from '../lib/args.js';
19
19
 
20
20
  // this is the path to the current project directory
21
21
  const appPath = process.cwd();
@@ -36,51 +36,15 @@ let caweb = deepmerge( testCaweb, defaultCaweb );
36
36
 
37
37
  let templatePath = path.join(appPath, 'node_modules', '@caweb', 'template');
38
38
  let template = getArgVal( 'template', path.join(templatePath, 'patterns', 'default.html') );
39
- let searchTemplate = getArgVal( 'search-template', path.join(templatePath, 'patterns', 'search.html') );
40
-
41
39
  let scheme = getArgVal( 'scheme', 'oceanside' );
42
40
  let favicon = caweb?.site?.favicon ?? null;
43
41
 
44
- // // Additional pages directory
45
- let basePageDir = path.join(appPath, 'content', 'pages');
46
-
47
- let additionalPages = ! fs.existsSync( basePageDir ) ? [] :
48
- fs.readdirSync( basePageDir, { withFileTypes: true, recursive: true } )
49
- .filter( dirent => dirent.isFile() && (dirent.name.endsWith('.html') || dirent.name.endsWith('.handlebars')) )
50
- .map( ( dirent ) => {
51
-
52
- let fileTemplate = path.join( dirent.parentPath, dirent.name );
53
-
54
- // replace .html, uppercase the first letter of each word
55
- // this is to make sure the title is readable
56
- // and not just a file name
57
- let title = dirent.name.replace('.html', '').replace(/\b\w/g, c => c.toUpperCase());
58
- let content = fs.readFileSync( fileTemplate, 'utf-8' );
59
- let data = {
60
- ...caweb.site,
61
- scheme
62
- };
63
- let compiler = Handlebars.compile( content );
64
- let compiledContent = compiler(data);
65
-
66
- return new HtmlWebpackPlugin({
67
- template,
68
- filename: fileTemplate.replace(basePageDir, ''),
69
- title,
70
- templateParameters: {
71
- ...caweb.site, // we spread the site data found in the caweb.json file
72
- scheme,
73
- partial: compiledContent,
74
- },
75
-
76
- });
77
- });
78
42
 
79
43
  export default {
80
44
  plugins: [
81
45
  // this plugin generates the main landing page using the template found in patterns/index.html
82
46
  new HtmlWebpackPlugin({
83
- template,
47
+ template: path.resolve(template),
84
48
  favicon,
85
49
  templateParameters: {
86
50
  ...caweb.site, // we spread the site data found in the caweb.json file
@@ -88,19 +52,5 @@ export default {
88
52
  }
89
53
  }),
90
54
 
91
- // this plugin generates Search Results page using the template found in patterns/search.html
92
- caweb?.site?.google?.search ? new HtmlWebpackPlugin({
93
- template: searchTemplate,
94
- favicon,
95
- filename: 'serp.html',
96
- title: 'Search Results Page',
97
- templateParameters: {
98
- ...caweb.site, // we spread the site data found in the caweb.json file
99
- scheme
100
- },
101
- }) : false,
102
-
103
- // this plugin generates additional pages under content/pages directory using the template found in patterns/index.html
104
- ...additionalPages
105
55
  ].filter(Boolean)
106
56
  };
package/webpack.config.js CHANGED
@@ -102,8 +102,7 @@ let webpackConfig = {
102
102
  filename: isProduction ? '[name].min.js' : '[name].js',
103
103
  chunkFilename: isProduction ? '[name].min.js?v=[chunkhash]' : '[name].js?v=[chunkhash]',
104
104
  pathinfo: false,
105
- clean: isProduction,
106
- publicPath: '/',
105
+ clean: isProduction
107
106
  },
108
107
 
109
108
  /**