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提交地址,便于用户反馈

  • 相关阅读:
    LNMP笔记:解决mail函数不能发送邮件
    OPENCART记录账户密码
    Nginx 0.8.5版本access.log日志分析shell命令
    几个查询信息的api接口
    chart 图表无法在显示
    RegularExpressionValidator
    用户 'WANGYACONG\ASPNET' 登录失败
    'IIS APPPOOL\ASP.NET V4.0' 登录失败
    正则表达式(转载)
    不小心删除了默认数据库的恢复方法
  • 原文地址:https://www.cnblogs.com/onesea/p/13282719.html
Copyright © 2011-2022 走看看