(初识MVC Core)三、包的安装NPM与打包--css和js

 一:NPM的安装

1.右键项目=》添加新建项=》创建NPM配置文件

 

2.新增引用插件包(会出现自动提示),写完一个之后,保存一下,就会自动安装插件包

 

 显示所有隐藏文件就可以看到安装的插件包了

 

 二:js和css打包bundleConfig.json

 1.新建一个名为bundleConfig.json的json

 

 2.打包

1)在项目wwwroot底下创建文件夹js和css

2)修改bundleConfig.json内容

 

[
  //css
  {
    //打捆生成的css文件路径和名称并压缩
    "outputFileName": "wwwroot/css/all.min.css",
    "inputFiles": [
      //需要打捆的css文件路径和名称
      "node_modules/bootstrap/dist/css/bootstrap.css",
      "wwwroot/css/site.css"
    ]
  },
  {
    "outputFileName": "wwwroot/css/bootstrap.css",
    "inputFiles": [
      "node_modules/bootstrap/dist/css/bootstrap.css"
    ],
    "minify": {
      "enabled": false//是否压缩(开发使用)
    }
  },
  //js
  {
    "outputFileName": "wwwroot/js/all.min.js",
    "inputFiles": [
      "node_modules/jquery-slim/dist/jquery.slim.js",
      "node_modules/popper.js/dist/js/popper.js",
      "node_modules/bootstrap/dist/js/bootstrap.js",
      "wwwroot/js/site.js"
    ],
    "minify": {
      "enabled": true,
      "renameLocals": true
    },
    "sourceMap": false
  },
  {
    "outputFileName": "wwwroot/js/vendor.js",
    "inputFiles": [
      "node_modules/jquery-slim/dist/jquery.slim.js",
      "node_modules/popper.js/dist/js/popper.js",
      "node_modules/bootstrap/dist/js/bootstrap.js"
    ],
    "minify": {
      "enabled": false
    }
  }
]

 

3)使用Nuget安装BuildBundlerMinifier

 

4)安装后执行一下,生成

 

 

参阅:https://v.qq.com/x/page/r0745234k98.html

谢谢Dave

 

转载于:https://www.cnblogs.com/dzw159/p/10569123.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值