@lipemat/js-boilerplate 10.5.1 → 10.6.0-beta.2

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/README.md CHANGED
@@ -41,6 +41,7 @@ Add the following to your package.json. (this may also be found in the `template
41
41
  * `brotliFiles : {bool}` Enabled generating pre-compressed .br files for CSS and JS.
42
42
  * `shortCssClasses : {bool}` Enable short 1-2 character CSS classes. Recommended if you're not running multiple instances of this package on the same site.
43
43
  * `jsPath : {string}` Path of JS application relative to `package.json`. If `package.json` is in same directory as the JS application, this may be omitted.
44
+ * `cssTsFiles : {bool}` Enable auto generation of TypeScript definitions for CSS modules.
44
45
 
45
46
  ## Code Completion In PHPStorm
46
47
  Some `@types` have been specified in this library to assist with code completion and allow using the built-in TypeScript support. Unfortunately, some typescripts still send errors to PHPStorm like "Default export is not declared in an imported module". I've found that it's easier to just remove this warning by un-checking `Editor -> Inspections -> JavaScript -> General -> Validate Imports`. (this may not need to be un-checked if you enable the built-in TypeScript support).
File without changes
@@ -2,7 +2,7 @@ const webpack = require( 'webpack' );
2
2
  const ReactRefreshWebpackPlugin = require( '@pmmmwh/react-refresh-webpack-plugin' );
3
3
  const path = require( 'path' );
4
4
  const ForkTsCheckerWebpackPlugin = require( 'fork-ts-checker-webpack-plugin' );
5
- const config = require( '../helpers/package-config' );
5
+ const {getPackageConfig} = require( '../helpers/package-config' );
6
6
  const {getEntries} = require( '../helpers/entries' );
7
7
  const {getConfig, getTsConfigFile, getBrowsersList} = require( '../helpers/config' );
8
8
 
@@ -46,15 +46,15 @@ module.exports = {
46
46
  },
47
47
  target: 'browserslist:' + getBrowsersList().join( ', ' ),
48
48
  output: {
49
- path: path.resolve( config.workingDirectory, 'dist' ),
49
+ path: path.resolve( getPackageConfig().workingDirectory, 'dist' ),
50
50
  filename: '[name].js',
51
- publicPath: config.url + ':' + devServerOptions.port + '/js/dist/',
51
+ publicPath: getPackageConfig().url + ':' + devServerOptions.port + '/js/dist/',
52
52
  chunkFilename: '[name].js',
53
53
  },
54
54
  resolve: {
55
55
  extensions: [ '.ts', '.tsx', '.js', '.jsx', '.json', '.pcss' ],
56
56
  modules: [
57
- path.resolve( config.workingDirectory, 'src' ),
57
+ path.resolve( getPackageConfig().workingDirectory, 'src' ),
58
58
  'node_modules',
59
59
  ],
60
60
  },
@@ -68,7 +68,7 @@ module.exports = {
68
68
  {
69
69
  test: /\.[jt]sx?$/,
70
70
  loader: 'babel-loader',
71
- include: path.resolve( config.workingDirectory, 'src' ),
71
+ include: path.resolve( getPackageConfig().workingDirectory, 'src' ),
72
72
  exclude: /node_modules/,
73
73
  options: babelOptions,
74
74
  },
@@ -87,6 +87,14 @@ module.exports = {
87
87
  test: /\.pcss$/,
88
88
  use: [
89
89
  'style-loader',
90
+ {
91
+ loader: '@teamsupercell/typings-for-css-modules-loader',
92
+ options: {
93
+ banner: '// Autogenerated by typings-for-css-modules-loader.',
94
+ disableLocalsExport: true,
95
+ prettierConfigFile: path.resolve( __dirname, '../helpers/.prettierrc.json' ),
96
+ },
97
+ },
90
98
  {
91
99
  loader: 'css-loader',
92
100
  options: cssLoaderOptions,
@@ -97,7 +105,12 @@ module.exports = {
97
105
  postcssOptions,
98
106
  },
99
107
  },
100
- ],
108
+ ].filter( loader => {
109
+ if ( ! getPackageConfig().cssTsFiles ) {
110
+ return loader.loader !== '@teamsupercell/typings-for-css-modules-loader';
111
+ }
112
+ return true;
113
+ } ),
101
114
  },
102
115
 
103
116
  ],
@@ -0,0 +1,6 @@
1
+ {
2
+ "singleQuote": true,
3
+ "useTabs": true,
4
+ "tabWidth": 4,
5
+ "endOfLine": "lf"
6
+ }
@@ -4,6 +4,7 @@ export interface PackageConfig {
4
4
  certificates?: Certificates;
5
5
  combinedJson: boolean;
6
6
  css_folder: string;
7
+ cssTsFiles: boolean;
7
8
  dependencies: Dependencies;
8
9
  description?: string;
9
10
  devDependencies: Dependencies;
@@ -39,5 +40,7 @@ export interface Scripts {
39
40
  test: string;
40
41
  }
41
42
 
42
- declare const packageConfig: PackageConfig;
43
+ declare const packageConfig: PackageConfig & {
44
+ getPackageConfig: () => PackageConfig;
45
+ };
43
46
  export default packageConfig;
@@ -12,6 +12,7 @@ packageConfig.url ||= 'http://localhost';
12
12
  // Path of JS application files.
13
13
  packageConfig.workingDirectory = packageConfig.jsPath !== '' ? path.resolve( packageConfig.jsPath ) : workingDirectory;
14
14
  packageConfig.shortCssClasses ||= false;
15
+ packageConfig.tsCssModules ||= false;
15
16
 
16
17
  try {
17
18
  const localConfig = require( path.resolve( workingDirectory, './local-config.json' ) );
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lipemat/js-boilerplate",
3
- "version": "10.5.1",
3
+ "version": "10.6.0-beta.2",
4
4
  "description": "Dependencies and scripts for a no config JavaScript app",
5
5
  "author": "Mat Lipe",
6
6
  "license": "MIT",
@@ -48,6 +48,7 @@
48
48
  "@lipemat/css-mqpacker": "^9.0.0",
49
49
  "@lipemat/eslint-config": "^3.1.3",
50
50
  "@pmmmwh/react-refresh-webpack-plugin": "^0.5.10",
51
+ "@teamsupercell/typings-for-css-modules-loader": "^2.5.2",
51
52
  "@types/node": "^16",
52
53
  "@wordpress/browserslist-config": "^5.19.0",
53
54
  "are-you-es5": "^2.1.1",
@@ -75,6 +76,7 @@
75
76
  "postcss-nested": "^5.0.6",
76
77
  "postcss-preset-env": "^7.5.0",
77
78
  "postcss-scss": "^4.0.4",
79
+ "prettier": "^3.1.1",
78
80
  "react": "^18.2.0",
79
81
  "react-dom": "^18.2.0",
80
82
  "react-refresh": "^0.14.0",
@@ -95,5 +97,5 @@
95
97
  "memfs": "^3.5.3",
96
98
  "setimmediate": "^1.0.5"
97
99
  },
98
- "packageManager": "yarn@3.6.4"
100
+ "packageManager": "yarn@4.0.2"
99
101
  }