Skip to content

Commit b25fe2a

Browse files
committed
modified: Modified the release command.
Modified: - Now `npm run release` will automatically call `npm run build`. - Also add a new command `npm run dev` to start webpack in dev mode. - Now using seperated config file for webpack in dev and prod. Update Github Action script to adapt this change.
1 parent cca85f7 commit b25fe2a

File tree

7 files changed

+60
-34
lines changed

7 files changed

+60
-34
lines changed

.github/workflows/webpack.yml

-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ jobs:
2525
- name: Build
2626
run: |
2727
npm install
28-
npm run build
2928
npm run release
3029
unzip release.zip -d ./artifact_content
3130
rm release.zip

docs/dev/renderer.md

+17-19
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
![Webpack](https://img.shields.io/badge/Webpack-grey?style=for-the-badge&logo=react&logoColor=white)
55

66
- [Introduction](#introduction)
7-
- [Bundling Using Webpack](#bundling-using-webpack)
7+
- [Start Developing](#start-developing)
88
- [Create Release Version](#create-release-version)
99
- [UI Development](#ui-development)
1010
- [Content Rendering Test Example](#content-rendering-test-example)
@@ -14,38 +14,36 @@
1414

1515
For how to clone and build this project, checkout the third method mentioned in [Installation Guide](/docs/plug_install.md).
1616

17-
## Bundling Using Webpack
17+
## Start Developing
1818

19-
All markdown rendering business is inside Renderer Process currently,
20-
and all code in Renderer process has been bundled to `dist/renderer.js` using `webpack`.
21-
So before start developing, run `npm install` to get all dependencies.
19+
First of all, run:
2220

23-
For a better dev experience, you could change the webpack config:
21+
```shell
22+
npm install
23+
```
2424

25-
```js
26-
module.exports = {
25+
This will help you get all deps used by this project. Then you can call:
2726

28-
watch: true, // rebundle when file changed
29-
mode: 'development', // enable webpack development mode
30-
// check out https://webpack.js.org/configuration/mode/ for more info.
31-
...// other configs
32-
};
27+
```shell
28+
npm run dev
3329
```
3430

35-
> Remember to change mode back to `production` when bundling release version.
31+
This will start `webpack` in watch mode with `development` flag enabled.
32+
3633

3734
## Create Release Version
3835

39-
`dist` directory is not included in `git`, to create a release version of this extension, please run:
36+
To create a release version of this extension, please run:
4037

4138
```shell
42-
npm run release
39+
npm run release # create Release.zip with ./dist included
4340
```
4441

45-
This script will:
42+
The script `npm run release` will:
4643

47-
- First use `git archive` to create a `release.zip` file contains all code included in `git`.
48-
- Use `zip -r` to add `dist` directory into previously generated `release.zip`.
44+
1. Run `npm run build` to generate `./dist` resources.
45+
2. Run `git archive` to create a `release.zip` file contains all code included in `git`.
46+
3. Run `zip -r` to add `dist` directory into previously generated `release.zip`.
4947

5048
# UI Development
5149

package-lock.json

+21-6
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+7-4
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,10 @@
1111
"zustand": "^4.5.4"
1212
},
1313
"scripts": {
14-
"build": "webpack",
15-
"release": "git archive -o release.zip HEAD && zip -r release.zip dist"
14+
"build": "webpack --config webpack.prod.js",
15+
"dev": "webpack --config webpack.dev.js",
16+
"release": "git archive -o release.zip HEAD && zip -r release.zip dist",
17+
"prerelease": "npm run build"
1618
},
1719
"devDependencies": {
1820
"@babel/core": "^7.24.7",
@@ -23,6 +25,7 @@
2325
"babel-loader": "^9.1.3",
2426
"webpack": "^5.92.1",
2527
"webpack-cli": "^5.1.4",
26-
"webpack-dev-server": "^5.0.4"
28+
"webpack-dev-server": "^5.0.4",
29+
"webpack-merge": "^6.0.1"
2730
}
28-
}
31+
}

webpack.config.js webpack.common.js

-4
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
11
const path = require("path");
22
module.exports = {
3-
4-
watch: false,
5-
mode: 'production',
6-
73
resolve: {
84
alias: {
95
"@": path.resolve(__dirname, "src"),

webpack.dev.js

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
const { merge } = require('webpack-merge');
2+
const common = require('./webpack.common.js');
3+
4+
module.exports = merge(common, {
5+
watch: true,
6+
mode: 'development',
7+
devtool: 'inline-source-map',
8+
});

webpack.prod.js

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
const { merge } = require('webpack-merge');
2+
const common = require('./webpack.common.js');
3+
4+
module.exports = merge(common, {
5+
watch: false,
6+
mode: 'production',
7+
});

0 commit comments

Comments
 (0)