浏览代码

add scripts

Paul 5 年前
父节点
当前提交
8ecf4bded5
共有 4 个文件被更改,包括 8 次插入6 次删除
  1. 3
    3
      package.json
  2. 1
    0
      scripts/jest/jest.config.js
  3. 2
    2
      scripts/webpack/webpack.config.dev.js
  4. 2
    1
      scripts/webpack/webpack.config.umd.js

+ 3
- 3
package.json 查看文件

@@ -7,11 +7,11 @@
7 7
   "scripts": {
8 8
     "type-check": "tsc --noEmit",
9 9
     "type-check:watch": "npm run type-check -- --watch",
10
-    "start": "webpack-dev-server --mode development",
11
-    "test": "jest",
10
+    "start": "webpack-dev-server --config scripts/webpack/webpack.config.dev.js",
11
+    "test": "jest --config=scripts/jest/jest.config.js",
12 12
     "build": "npm run clean && npm run build:cjs && npm run build:umd",
13 13
     "build:cjs": "tsc --project ./tsconfig.cjs.json",
14
-    "build:umd": "NODE_ENV=production webpack --config ./webpack.config.prod.js",
14
+    "build:umd": "NODE_ENV=production webpack --config scripts/webpack/webpack.config.umd.js",
15 15
     "clean": "rimraf dist"
16 16
   },
17 17
   "repository": {

jest.config.js → scripts/jest/jest.config.js 查看文件

@@ -2,6 +2,7 @@ module.exports = {
2 2
   transform: {
3 3
     '^.+\\.tsx?$': 'ts-jest',
4 4
   },
5
+  rootDir: '../../',
5 6
   testRegex: '(/test/.*|(\\.|/)(test|spec))\\.(jsx?|tsx?)$',
6 7
   moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'json', 'node'],
7 8
 };

webpack.config.js → scripts/webpack/webpack.config.dev.js 查看文件

@@ -1,6 +1,7 @@
1 1
 /* eslint-disable @typescript-eslint/no-var-requires */
2 2
 
3 3
 const path = require('path');
4
+const rootPath = process.cwd();
4 5
 const HtmlWebpackPlugin = require('html-webpack-plugin');
5 6
 
6 7
 module.exports = {
@@ -8,7 +9,6 @@ module.exports = {
8 9
   entry: './example/main.ts',
9 10
   devtool: 'inline-source-map',
10 11
   devServer: {
11
-    contentBase: './dist',
12 12
     compress: true,
13 13
     hot: true,
14 14
   },
@@ -19,7 +19,7 @@ module.exports = {
19 19
   ],
20 20
   output: {
21 21
     filename: '[name].bundle.js',
22
-    path: path.resolve(__dirname, 'dist'),
22
+    path: path.resolve(rootPath, 'dist'),
23 23
   },
24 24
   resolve: { extensions: ['.js', '.jsx', '.tsx', '.ts', '.json'] },
25 25
   module: {

webpack.config.prod.js → scripts/webpack/webpack.config.umd.js 查看文件

@@ -1,6 +1,7 @@
1 1
 /* eslint-disable @typescript-eslint/no-var-requires */
2 2
 
3 3
 const path = require('path');
4
+const rootPath = process.cwd();
4 5
 
5 6
 module.exports = {
6 7
   mode: 'production',
@@ -8,7 +9,7 @@ module.exports = {
8 9
   devtool: false,
9 10
   output: {
10 11
     filename: 'index.js',
11
-    path: path.resolve(__dirname, 'dist/umd'),
12
+    path: path.resolve(rootPath, 'dist/umd'),
12 13
     library: 'imSdk',
13 14
     libraryTarget: 'umd',
14 15
   },