🚀 Socket Launch Week Day 5:Introducing Repository Access Permissions and Custom Roles.Learn more
Sign In

@nioh/pack

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@nioh/pack

basic webpack config, easy for build

latest
npmnpm
Version
1.1.0
Version published
Weekly downloads
3
-66.67%
Maintainers
1
Weekly downloads
 
Created
Source

@@nioh/pack

基础 webpack 依赖包

Install

$ npm install -D @@nioh/pack

Usage

const {client, helper} = require('@@nioh/pack')

helper
  .set('baseDir', __dirname)        // 必填
  .set('preset', 'vue')             // 可选,支持 vue, react, 将不同的处理
  .set('patch', (rules, plugins) => {
    // 修改默认 loader 和 plugin,可选
    console.log(rules, plugins)
    // 举例:修改默认配置中 babel-loader 的 presets 和 plugins
    rules.babel.use.options.presets.push('@babel/preset-react')
  })

// 可选,仅针对基于 @nioh/core 项目,配置在Koa项目中入口
helper.set('entryInKoa', ['client'])

module.exports = client

管理输入输出

  • 基于@nioh/core 项目,使用 helper.set 配置 entryInKoa,将自动设置输入输出
helper.set('entryInKoa', ['client'])
  • 独立项目,需要用 helper.merge 配置 entry 和 output, 使用绝对路径
const config = helper.merge(client, {
  entry: {
    client: helper.resolve(__dirname, 'client.js')
  },
  output: {
    path: helper.resolve(__dirname, 'dist'),
    publicPath: '/runtime/'
  }
})

API

helper.set: 设置基础配置,baseDir,preset,patch,entryInKoa

helper.resolve: path.resolve

helper.merge: webpack-merge

默认支持目录结构

project
|———— components
|———— app.js
|———— webpack.config.js

FAQs

Package last updated on 14 Oct 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts