zoukankan      html  css  js  c++  java
  • package.json配置详解

    默认的package.json文件直接使用命令:npm init --yes生成

    {
    "name": "pingdingshan",
    "version": "1.0.0",
    "description": "",
    "main": "index.js",
    "scripts": {
    "test": "echo "Error: no test specified" && exit 1"
    },
    "author": "",
    "license": "ISC"
    }

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    name:包名字
    version:包版本,x.x.x的格式,符合语义化版本规则
    description:一些描述信息
    main:入口文件,一般是index.js
    scripts:指定了运行脚本命令的npm命令行缩写,默认是空的test
    author:作者信息
    license:许可证,默认是ISC、有的默认是MIT
    npm run 可列出package.json中scripts的所有脚本命令
    npm run test就会执行:echo “Error: no test specified” && exit 1

    以我们公司项目的package.json文件部分为例:

    {
    "name": "h5-components",
    "version": "1.2.0",
    "description": "",
    "main": "./lib/index",
    "module": "./es/index",
    "files": [
    "lib",
    "es",
    "dist",
    "assets"
    ],
    "repository": "http://.../h5-components.git",
    "homepage": "http://...",
    "author": "",
    "license": "MIT",
    "scripts": {
    "dll": "webpack --config webpack.dll.config.js",
    "rccompile": "rc-tools run compile --babel-runtime --copy-files",
    "dev": "webpack-dev-server --env.api dev",
    "rcdist": "rc-tools run dist",
    "ucs": "yarn upgrade h5-css",
    "rclint": "rc-tools run lint",
    "build": "yarn rccompile && git add . && git commit -m '[compile]' && git pull && git push"
    },
    "config": {
    "port": 8089,
    "entry": {
    "h5-components": [
    "./index.js"
    ]
    }
    },
    "dependencies": {
    "antd-mobile": "^2.2.0",
    "classnames": "^2.2.1",
    "exif-js": "^2.3.0"
    },
    "devDependencies": {
    "file-loader": "^1.1.5",
    "less-loader": "^4.1.0",
    "lodash": "^4.17.4",
    "lodash-webpack-plugin": "^0.11.4",
    "mini-css-extract-plugin": "^0.4.1"
    },
    "sideEffects": [
    "*.scss"
    ],
    "browserslist": [
    "iOS >= 8",
    "Firefox >= 20",
    "Android > 4.2",
    "> 1%",
    "last 2 versions",
    "not ie <= 10"
    ]
    }

    1

    module:es6编译入口文件
    main:es5编译入口文件
    files:包含在项目中的文件(夹)数组,可以声明一个.gitignore来忽略部分文件
    repository:项目代码存放的地方
    homepage: 项目主页url,(包的官网)
    config:字段用于添加命令行的环境变量。
    dependencies:在生产环境中需要用到的依赖
    devDependencies:在开发、测试环境中用到的依赖
    sideEffects:如果没有这个值,打包时会出错,参照css issue
    browserslist:指定该模板供浏览器使用的版本
    bugs:填写一个bug提交地址,便于用户反馈

  • 相关阅读:
    04 链表(上):如何实现LRU缓存淘汰算法?
    03 数组:为什么很多编程语言中数组都从0开始编号?
    02 复杂度分析(下):浅析最好、最坏、平均、均摊时间复杂度
    01 复杂度分析(上):如何分析、统计算法的执行效率和资源消耗?
    Winform PictureBox图片旋转
    我的第一篇博客
    redis分布式锁实现与思考
    java 时间字符串中毫秒值时有时无,怎么解析
    spring 接收处理 json 类型的请求(spring 默认使用jackson 处理接收的数据), json 字段的中的Date 类型会自动 转换为 Long 类型
    java 中的正则使用
  • 原文地址:https://www.cnblogs.com/onesea/p/13282719.html
Copyright © 2011-2022 走看看