diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 00000000..19302a62 --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,16 @@ +{ + "version": "1.0.0", + "configurations": [ + { + "type": "node", + "request": "launch", + "name": "Jest: current file", + "program": "${workspaceFolder}/node_modules/.bin/jest", + "args": ["${fileBasenameNoExtension}", "--config", "jest.config.ts"], + "console": "integratedTerminal", + "windows": { + "program": "${workspaceFolder}/node_modules/jest/bin/jest" + } + } + ] + } diff --git a/docs/swc/configure-build.md b/docs/swc/configure-build.md index 957fc5c5..6677acd4 100644 --- a/docs/swc/configure-build.md +++ b/docs/swc/configure-build.md @@ -48,7 +48,7 @@ import { browserslistToSwc, defineBuildConfig } from "@workleap/swc-configs"; const targets = browserslistToSwc(); -export default defineBuildConfig(targets); +export const swcConfig = defineBuildConfig(targets); ``` ### `targets` @@ -76,7 +76,7 @@ import { browserslistToSwc, defineBuildConfig } from "@workleap/swc-configs"; const targets = browserslistToSwc({ queries: ["extends @workleap/browserslist-config"] }) -export default defineBuildConfig(targets); +export const swcConfig = defineBuildConfig(targets); ``` Or load the closest `.browserslistrc` configuration file and convert the queries into SWC targets: @@ -92,7 +92,7 @@ import { browserslistToSwc, defineBuildConfig } from "@workleap/swc-configs"; const targets = browserslistToSwc(); -export default defineBuildConfig(targets); +export const swcConfig = defineBuildConfig(targets); ``` The `browserslistToSwc(options)` utility function accepts any option supported by Browserslist [JS API](https://github.com/browserslist/browserslist#js-api) in addition to a `queries` option: @@ -117,7 +117,7 @@ import { browserslistToSwc, defineBuildConfig } from "@workleap/swc-configs"; const targets = browserslistToSwc(); -export default defineBuildConfig(targets, { +export const swcConfig = defineBuildConfig(targets, { parser: "ecmascript" }); ``` @@ -154,7 +154,7 @@ function mangleMinifiedCode(config) { return config; } -export default defineBuildConfig(targets, { +export const swcConfig = defineBuildConfig(targets, { transformers: [mangleMinifiedCode] }); ``` diff --git a/docs/swc/configure-dev.md b/docs/swc/configure-dev.md index 8f9a0192..fc6ee028 100644 --- a/docs/swc/configure-dev.md +++ b/docs/swc/configure-dev.md @@ -48,7 +48,7 @@ import { browserslistToSwc, defineDevConfig } from "@workleap/swc-configs"; const targets = browserslistToSwc(); -export default defineDevConfig(targets); +export const swcConfig = defineDevConfig(targets); ``` ### `targets` @@ -76,7 +76,7 @@ import { browserslistToSwc, defineDevConfig } from "@workleap/swc-configs"; const targets = browserslistToSwc({ queries: ["extends @workleap/browserslist-config"] }); -export default defineDevConfig(targets); +export const swcConfig = defineDevConfig(targets); ``` Or load the closest `.browserslistrc` configuration file and convert the queries into SWC targets: @@ -92,7 +92,7 @@ import { browserslistToSwc, defineDevConfig } from "@workleap/swc-configs"; const targets = browserslistToSwc(); -export default defineDevConfig(targets); +export const swcConfig = defineDevConfig(targets); ``` The `browserslistToSwc(options)` utility function accepts any option supported by Browserslist [JS API](https://github.com/browserslist/browserslist#js-api) in addition to a `queries` option: @@ -117,7 +117,7 @@ import { browserslistToSwc, defineDevConfig } from "@workleap/swc-configs"; const targets = browserslistToSwc(); -export default defineDevConfig(targets, { +export const swcConfig = defineDevConfig(targets, { fastRefresh: false }); ``` @@ -136,7 +136,7 @@ import { browserslistToSwc, defineDevConfig } from "@workleap/swc-configs"; const targets = browserslistToSwc(); -export default defineDevConfig(targets, { +export const swcConfig = defineDevConfig(targets, { parser: "ecmascript" }); ``` @@ -173,7 +173,7 @@ function disableReactBuiltins(config) { return config; } -export default defineDevConfig(targets, { +export const swcConfig = defineDevConfig(targets, { transformers: [disableReactBuiltins] }); ``` diff --git a/docs/swc/configure-jest.md b/docs/swc/configure-jest.md index 55e076ab..2c8b04c3 100644 --- a/docs/swc/configure-jest.md +++ b/docs/swc/configure-jest.md @@ -49,7 +49,7 @@ Then, open the newly created file and export the SWC configuration by using the ```ts !#6-8 swc.jest.ts import { defineJestConfig } from "@workleap/swc-configs"; -export default defineJestConfig(); +export const swcConfig = defineJestConfig(); ``` ## 3. Set predefined options @@ -66,7 +66,7 @@ Whether or not to transform React code. ```ts !#4 swc.jest.ts import { defineJestConfig } from "@workleap/swc-configs"; -export default defineJestConfig({ +export const swcConfig = defineJestConfig({ react: true }); ``` @@ -81,7 +81,7 @@ Whether SWC should expect to parse JavaScript or TypeScript code. ```ts !#4 swc.jest.ts import { defineJestConfig } from "@workleap/swc-configs"; -export default defineJestConfig({ +export const swcConfig = defineJestConfig({ parser: "ecmascript" }); ``` @@ -114,7 +114,7 @@ const useCommonJsModules: SwcConfigTransformer = (config: SwcConfig) => { return config; }; -export default defineJestConfig({ +export const swcConfig = defineJestConfig({ transformers: [useCommonJsModules] }); ``` diff --git a/docs/webpack/configure-build.md b/docs/webpack/configure-build.md index f37bfe02..4ed131e1 100644 --- a/docs/webpack/configure-build.md +++ b/docs/webpack/configure-build.md @@ -29,6 +29,8 @@ npm install -D @workleap/webpack-configs webpack webpack-cli @swc/core @swc/help ## 2. Configure webpack +### HTML template + First, create a `public` folder with an `index.html` file at the root of the project: ``` !#2-3 @@ -56,6 +58,8 @@ Then, open the newly created `index.html` file and copy/paste the following cont The content of the `public/index.html` file is the default template that will be used by [HtmlWebpackPlugin](https://webpack.js.org/plugins/html-webpack-plugin/). +### defineBuildConfig + Next, create a configuration file named `webpack.build.js` at the root of the project: ``` !#5 @@ -77,7 +81,7 @@ import { swcConfig } from "./swc.build.js"; export default defineBuildConfig(swcConfig); ``` -### `swcConfig` +### swcConfig In the previous code sample, the `defineBuildConfig(swcConfig, options)` function receive an SWC [configuration object](https://swc.rs/docs/configuration/swcrc) through the `swcConfig` parameter. diff --git a/docs/webpack/configure-dev.md b/docs/webpack/configure-dev.md index bb9237df..45f5cd07 100644 --- a/docs/webpack/configure-dev.md +++ b/docs/webpack/configure-dev.md @@ -15,20 +15,22 @@ Open a terminal at the root of the project and install the following packages: +++ pnpm ```bash -pnpm add -D @workleap/webpack-configs webpack webpack-cli webpack-dev-server @swc/core @swc/helpers browserslist postcss +pnpm add -D @workleap/webpack-configs webpack webpack-cli webpack-dev-server @swc/core @swc/helpers browserslist postcss nodemon ``` +++ yarn ```bash -yarn add -D @workleap/webpack-configs webpack webpack-cli webpack-dev-server @swc/core @swc/helpers browserslist postcss +yarn add -D @workleap/webpack-configs webpack webpack-cli webpack-dev-server @swc/core @swc/helpers browserslist postcss nodemon ``` +++ npm ```bash -npm install -D @workleap/webpack-configs webpack webpack-cli webpack-dev-server @swc/core @swc/helpers browserslist postcss +npm install -D @workleap/webpack-configs webpack webpack-cli webpack-dev-server @swc/core @swc/helpers browserslist postcss nodemon ``` +++ ## 2. Configure webpack +### HTML template + First, create a `public` folder with an `index.html` file at the root of the project: ``` !#2-3 @@ -38,7 +40,6 @@ web-project ├── src ├──── ... ├── package.json -├── webpack.dev.js ``` Then, open the newly created `index.html` file and copy/paste the following content: @@ -56,10 +57,44 @@ Then, open the newly created `index.html` file and copy/paste the following cont The content of the `public/index.html` file is the default template that will be used by [HtmlWebpackPlugin](https://webpack.js.org/plugins/html-webpack-plugin/). +#### Adding local assets + +To link local assets such as a `favicon.png` in the default HTML template, it is recommended to preprend the **relative** path of every asset with the `publicPath` of the webpack config. + +First, add the asset to the `public` folder at the root of the project: + +``` !#4 +web-project +├── public +├──── index.html +├──── favicon.png +├── src +├──── ... +├── package.json +``` + +Then, add the assets to the `index.html` file: + +```html !#4 public/index.html + + + + + + +
+ + +``` + +### defineDevConfig + Next, create a configuration file named `webpack.dev.js` at the root of the project: -``` !#5 +``` !#7 web-project +├── public +├──── index.html ├── src ├──── ... ├── package.json @@ -77,7 +112,7 @@ import { swcConfig } from "./swc.dev.js"; export default defineDevConfig(swcConfig); ``` -### `swcConfig` +### swcConfig In the previous code sample, the `defineDevConfig(swcConfig, options)` function receive an SWC [configuration object](https://swc.rs/docs/configuration/swcrc) through the `swcConfig` parameter. @@ -415,17 +450,45 @@ Modifying a webpack configuration object can be an arduous task, to help with th [!ref Transformer utilities](transformer-utilities.md) -## 5. Add a CLI script +## 5. Setup nodemon + +[Nodemon](https://nodemon.io/) is a utility that will monitor for any changes in the `swc.dev.js` and `webpack.dev.dev.js` files and restart the webpack development server whenever a change occurs. + +First, add a `nodemon.json` file at the root of the project: + +``` !#8 +web-project +├── public +├──── index.html +├── src +├──── ... +├── package.json +├── webpack.dev.js +├── nodemon.json +``` + +Then, open the `nodemon.json` file and copy/paste the following content: + +```json nodemon.json +{ + "watch": ["swc.dev.js", "webpack.dev.js"], + "exec": "webpack serve --config webpack.dev.js" +} +``` + +Finally, add a CLI script at the [next step](#6-add-a-cli-script) of this guide. + +## 6. Add a CLI script To initiate the development server, add the following script to your project `package.json` file: ```json package.json { - "dev": "webpack serve --config webpack.dev.js" + "dev": "nodemon" } ``` -## 6. Set environment variables +## 7. Set environment variables To deal with environment variables, the webpack documentation suggests using the [--env option](https://webpack.js.org/guides/environment-variables/) from its CLI. While that would work, by using webpack `--env` CLI option, the environment variables would only be made available to the webpack configuration files (.e.g. `webpack.dev.js`) rather than any Node.js files. Therefore we **do not recommend** using webpack `--env` CLI option. @@ -435,7 +498,7 @@ We recommend instead to define environment variables using [cross-env](https://g ```json package.json { - "dev": "cross-env DEBUG=true webpack serve --config webpack.dev.js" + "dev": "cross-env DEBUG=true nodemon" } ``` @@ -492,8 +555,8 @@ export function App() { The `=== "true"` part of `"DEBUG": process.env.DEBUG === "true"` is very important, otherwise the environment variable value would be `"true"` instead of `true`. !!! -## 7. Try it :rocket: +## 8. Try it :rocket: -To test your new webpack configuration, open a terminal at the root of the project and execute the [CLI script added earlier](#5-add-a-cli-script). A development server should start without outputting any error in the terminal. +To test your new webpack configuration, open a terminal at the root of the project and execute the [CLI script added earlier](#6-add-a-cli-script). A development server should start without outputting any error in the terminal. diff --git a/packages/webpack-configs/src/build.ts b/packages/webpack-configs/src/build.ts index 7966df46..fd0fb25a 100644 --- a/packages/webpack-configs/src/build.ts +++ b/packages/webpack-configs/src/build.ts @@ -3,6 +3,7 @@ import HtmlWebpackPlugin from "html-webpack-plugin"; import MiniCssExtractPlugin from "mini-css-extract-plugin"; import { createRequire } from "node:module"; import path from "node:path"; +import { fileURLToPath } from "node:url"; import TerserPlugin from "terser-webpack-plugin"; import type { Configuration as WebpackConfig } from "webpack"; import webpack from "webpack"; @@ -17,6 +18,9 @@ const DefinePlugin = webpack.DefinePlugin; // is available const require = createRequire(import.meta.url); +// The equivalent of __filename for CommonJS. +const __filename = fileURLToPath(import.meta.url); + type MiniCssExtractPluginOptions = NonNullable[number]>; export function defineBuildHtmlWebpackPluginConfig(options: HtmlWebpackPlugin.Options = {}): HtmlWebpackPlugin.Options { @@ -104,8 +108,14 @@ export function defineBuildConfig(swcConfig: SwcConfig, options: DefineBuildConf cache: cache && { type: "filesystem", allowCollectingMemory: false, - cacheDirectory: cacheDirectory + cacheDirectory: cacheDirectory, + maxMemoryGenerations: 1, + // Took from https://webpack.js.org/configuration/cache/#cachebuilddependencies. + buildDependencies: { + config: [__filename] + } }, + // (ACTUALLY NOT FIXING ANYTHING AT THE MOMENT) // Fixes caching for environmental variables using the DefinePlugin by forcing // webpack caching to prioritize hashes over timestamps. snapshot: cache ? { diff --git a/packages/webpack-configs/src/dev.ts b/packages/webpack-configs/src/dev.ts index 8c3435d5..483c51c7 100644 --- a/packages/webpack-configs/src/dev.ts +++ b/packages/webpack-configs/src/dev.ts @@ -4,6 +4,7 @@ import type { Config as SwcConfig } from "@swc/core"; import HtmlWebpackPlugin from "html-webpack-plugin"; import { createRequire } from "node:module"; import path from "node:path"; +import { fileURLToPath } from "node:url"; import type { Configuration as WebpackConfig } from "webpack"; import webpack from "webpack"; import { applyTransformers, type WebpackConfigTransformer } from "./transformers/applyTransformers.ts"; @@ -20,6 +21,9 @@ const DefinePlugin = webpack.DefinePlugin; // is available const require = createRequire(import.meta.url); +// The equivalent of __filename for CommonJS. +const __filename = fileURLToPath(import.meta.url); + export function defineDevHtmlWebpackPluginConfig(options: HtmlWebpackPlugin.Options = {}): HtmlWebpackPlugin.Options { const { template = path.resolve("./public/index.html"), @@ -111,8 +115,13 @@ export function defineDevConfig(swcConfig: SwcConfig, options: DefineDevConfigOp type: "filesystem", allowCollectingMemory: true, maxMemoryGenerations: 1, - cacheDirectory: cacheDirectory + cacheDirectory: cacheDirectory, + // Took from https://webpack.js.org/configuration/cache/#cachebuilddependencies. + buildDependencies: { + config: [__filename] + } }, + // (ACTUALLY NOT FIXING ANYTHING AT THE MOMENT) // Fixes caching for environmental variables using the DefinePlugin by forcing // webpack caching to prioritize hashes over timestamps. snapshot: cache ? { diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 96f84219..850b9c34 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -478,6 +478,9 @@ importers: msw: specifier: 1.3.0 version: 1.3.0(typescript@5.2.2) + nodemon: + specifier: 3.0.1 + version: 3.0.1 postcss: specifier: 8.4.29 version: 8.4.29 @@ -3931,6 +3934,10 @@ packages: resolution: {integrity: sha512-j2afSsaIENvHZN2B8GOpF566vZ5WVk5opAiMTvWgaQT8DkbOqsTfvNAvHoRGU2zzP8cPoqys+xHTRDWW8L+/BA==} dev: true + /abbrev@1.1.1: + resolution: {integrity: sha512-nne9/IiQ/hzIhY6pdDnbBtz7DjPTKrY00P/zvPSm5pOFkl6xuGrGnXn/VtTNNfNtAfZ9/1RtehkszU9qcTii0Q==} + dev: true + /abbrev@2.0.0: resolution: {integrity: sha512-6/mh1E2u2YgEsCHdY0Yx5oW+61gZU+1vXaoiHHrpKeuRNNgFvS+/jrwHiQhB5apAf5oB7UB7E19ol2R2LKH8hQ==} engines: {node: ^14.17.0 || ^16.13.0 || >=18.0.0} @@ -5051,7 +5058,7 @@ packages: dependencies: ms: 2.0.0 - /debug@3.2.7: + /debug@3.2.7(supports-color@5.5.0): resolution: {integrity: sha512-CFjzYYAi4ThfiQvizrFQevTTXHtnCqWfe7x1AhgEscTz6ZbLbfoLRLPugTQyBth6f8ZERVUSyWHFD/7Wu4t1XQ==} peerDependencies: supports-color: '*' @@ -5060,6 +5067,7 @@ packages: optional: true dependencies: ms: 2.1.3 + supports-color: 5.5.0 /debug@4.3.4: resolution: {integrity: sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==} @@ -5564,7 +5572,7 @@ packages: /eslint-import-resolver-node@0.3.9: resolution: {integrity: sha512-WFj2isz22JahUv+B788TlO3N6zL3nNJGU8CcZbPZvVEkBPaJdCV4vy5wyghty5ROFbCRnm132v8BScu5/1BQ8g==} dependencies: - debug: 3.2.7 + debug: 3.2.7(supports-color@5.5.0) is-core-module: 2.13.0 resolve: 1.22.4 transitivePeerDependencies: @@ -5618,7 +5626,7 @@ packages: optional: true dependencies: '@typescript-eslint/parser': 6.6.0(eslint@8.49.0)(typescript@5.2.2) - debug: 3.2.7 + debug: 3.2.7(supports-color@5.5.0) eslint: 8.49.0 eslint-import-resolver-node: 0.3.9 transitivePeerDependencies: @@ -5640,7 +5648,7 @@ packages: array.prototype.findlastindex: 1.2.3 array.prototype.flat: 1.3.2 array.prototype.flatmap: 1.3.2 - debug: 3.2.7 + debug: 3.2.7(supports-color@5.5.0) doctrine: 2.1.0 eslint: 8.49.0 eslint-import-resolver-node: 0.3.9 @@ -6652,6 +6660,10 @@ packages: resolution: {integrity: sha512-dcyqhDvX1C46lXZcVqCpK+FtMRQVdIMN6/Df5js2zouUsqG7I6sFxitIC+7KYK29KdXOLHdu9zL4sFnoVQnqaA==} dev: true + /ignore-by-default@1.0.1: + resolution: {integrity: sha512-Ius2VYcGNk7T90CppJqcIkS5ooHUZyIQK+ClZfMfMNFEF9VSE73Fq+906u/CWu92x4gzZMWOwfFYckPObzdEbA==} + dev: true + /ignore@5.2.4: resolution: {integrity: sha512-MAb38BcSbH0eHNBxn7ql2NH/kX33OkB3lZ1BNdh7ENeRChHTYsTvWrMubiIAMNS2llXEEgZ1MUOBtXChP3kaFQ==} engines: {node: '>= 4'} @@ -8551,6 +8563,30 @@ packages: /node-releases@2.0.13: resolution: {integrity: sha512-uYr7J37ae/ORWdZeQ1xxMJe3NtdmqMC/JZK+geofDrkLUApKRHPd18/TxtBOJ4A0/+uUIliorNrfYV6s1b02eQ==} + /nodemon@3.0.1: + resolution: {integrity: sha512-g9AZ7HmkhQkqXkRc20w+ZfQ73cHLbE8hnPbtaFbFtCumZsjyMhKk9LajQ07U5Ux28lvFjZ5X7HvWR1xzU8jHVw==} + engines: {node: '>=10'} + hasBin: true + dependencies: + chokidar: 3.5.3 + debug: 3.2.7(supports-color@5.5.0) + ignore-by-default: 1.0.1 + minimatch: 3.1.2 + pstree.remy: 1.1.8 + semver: 7.5.4 + simple-update-notifier: 2.0.0 + supports-color: 5.5.0 + touch: 3.1.0 + undefsafe: 2.0.5 + dev: true + + /nopt@1.0.10: + resolution: {integrity: sha512-NWmpvLSqUrgrAC9HCuxEvb+PSloHpqVu+FqcO4eeF2h5qYRhA7ev6KvelyQAKtegUbC6RypJnlEOhd8vloNKYg==} + hasBin: true + dependencies: + abbrev: 1.1.1 + dev: true + /nopt@7.2.0: resolution: {integrity: sha512-CVDtwCdhYIvnAzFoJ6NJ6dX3oga9/HyciQDnG1vQDjSLMeKLJ4A93ZqYKDrgYSr1FBY5/hMYC+2VCi24pgpkGA==} engines: {node: ^14.17.0 || ^16.13.0 || >=18.0.0} @@ -8962,7 +8998,7 @@ packages: engines: {node: '>= 0.12.0'} dependencies: async: 2.6.4 - debug: 3.2.7 + debug: 3.2.7(supports-color@5.5.0) mkdirp: 0.5.6 transitivePeerDependencies: - supports-color @@ -9469,6 +9505,10 @@ packages: resolution: {integrity: sha512-E/ZsdU4HLs/68gYzgGTkMicWTLPdAftJLfJFlLUAAKZGkStNU72sZjT66SnMDVOfOWY/YAoiD7Jxa9iHvngcag==} dev: true + /pstree.remy@1.1.8: + resolution: {integrity: sha512-77DZwxQmxKnu3aR542U+X8FypNzbfJ+C5XQDk3uWjWxn6151aIMGthWYRXTqT1E5oJvg+ljaa2OJi+VfvCOQ8w==} + dev: true + /punycode@2.3.0: resolution: {integrity: sha512-rRV+zQD8tVFys26lAGR9WUuS4iUAngJScM+ZRSKtvl5tKeZ2t5bvdNFdNHBW9FWR4guGHlgmsZ1G7BSm2wTbuA==} engines: {node: '>=6'} @@ -10087,6 +10127,13 @@ packages: resolution: {integrity: sha512-bzyZ1e88w9O1iNJbKnOlvYTrWPDl46O1bG0D3XInv+9tkPrxrN8jUUTiFlDkkmKWgn1M6CfIA13SuGqOa9Korw==} engines: {node: '>=14'} + /simple-update-notifier@2.0.0: + resolution: {integrity: sha512-a2B9Y0KlNXl9u/vsW6sTIu9vGEpfKu2wRV6l1H3XEas/0gUIzGzBoP/IouTcUQbm9JWZLH3COxyn03TYlFax6w==} + engines: {node: '>=10'} + dependencies: + semver: 7.5.4 + dev: true + /sisteransi@1.0.5: resolution: {integrity: sha512-bLGGlR1QxBcynn2d5YmDX4MGjlZvy2MRBDRNHLJ8VI6l6+9FUiyTFNJ0IveOSP0bcXgVDPRcfGqA0pjaqUpfVg==} @@ -10702,6 +10749,13 @@ packages: resolution: {integrity: sha512-o5sSPKEkg/DIQNmH43V0/uerLrpzVedkUh8tGNvaeXpfpuwjKenlSox/2O/BTlZUtEe+JG7s5YhEz608PlAHRA==} engines: {node: '>=0.6'} + /touch@3.1.0: + resolution: {integrity: sha512-WBx8Uy5TLtOSRtIq+M03/sKDrXCLHxwDcquSP2c43Le03/9serjQBIztjRz6FkJez9D/hleyAXTBGLwwZUw9lA==} + hasBin: true + dependencies: + nopt: 1.0.10 + dev: true + /tough-cookie@4.1.3: resolution: {integrity: sha512-aX/y5pVRkfRnfmuX+OdbSdXvPe6ieKX/G2s7e98f4poJHnqH3281gDPm/metm6E/WRamfx7WC4HUqkWHfQHprw==} engines: {node: '>=6'} @@ -11013,6 +11067,10 @@ packages: has-symbols: 1.0.3 which-boxed-primitive: 1.0.2 + /undefsafe@2.0.5: + resolution: {integrity: sha512-WxONCrssBM8TSPRqN5EmsjVrsv4A8X12J4ArBiiayv3DyyG3ZlIg6yysuuSYdZsVz3TKcTg2fd//Ujd4CHV1iA==} + dev: true + /unicode-canonical-property-names-ecmascript@2.0.0: resolution: {integrity: sha512-yY5PpDlfVIU5+y/BSCxAJRBIS1Zc2dDG3Ujq+sR0U+JjUevW2JhocOF+soROYDSaAezOzOKuyyixhD6mBknSmQ==} engines: {node: '>=4'} diff --git a/sample/app/nodemon.json b/sample/app/nodemon.json new file mode 100644 index 00000000..7a5919df --- /dev/null +++ b/sample/app/nodemon.json @@ -0,0 +1,5 @@ +{ + "watch": ["swc.dev.js", "webpack.dev.js"], + "exec": "webpack serve --config webpack.dev.js", + "verbose": true +} diff --git a/sample/app/package.json b/sample/app/package.json index a194b1f2..9c163a60 100644 --- a/sample/app/package.json +++ b/sample/app/package.json @@ -10,10 +10,10 @@ "workerDirectory": "public" }, "scripts": { - "dev": "webpack serve --config webpack.dev.js", - "dev-msw": "cross-env USE_MSW=true webpack serve --config webpack.dev.js", - "dev-verbose": "cross-env VERBOSE=true webpack serve --config webpack.dev.js", - "dev-msw-verbose": "cross-env USE_MSW=true VERBOSE=true webpack serve --config webpack.dev.js", + "dev": "nodemon", + "dev-msw": "cross-env USE_MSW=true nodemon", + "dev-verbose": "cross-env VERBOSE=true nodemon", + "dev-msw-verbose": "cross-env USE_MSW=true VERBOSE=true nodemon", "build": "webpack --config webpack.build.js", "serve-build": "pnpm build && pnpm http-server dist -p 8080 -P http://localhost:8080? -c-1", "build-verbose": "cross-env PROFILE=true webpack --config webpack.build.js" @@ -42,6 +42,7 @@ "jest": "29.6.4", "jest-environment-jsdom": "29.6.4", "msw": "1.3.0", + "nodemon": "3.0.1", "postcss": "8.4.29", "postcss-preset-env": "9.1.3", "ts-jest": "29.1.1", diff --git a/sample/app/public/favicon.png b/sample/app/public/favicon.png new file mode 100644 index 00000000..47157f6b Binary files /dev/null and b/sample/app/public/favicon.png differ diff --git a/sample/app/public/index.html b/sample/app/public/index.html index a667bb44..74bd0a31 100644 --- a/sample/app/public/index.html +++ b/sample/app/public/index.html @@ -1,6 +1,7 @@ +