• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

krasimir/webpack-library-starter: Webpack based boilerplate for producing librar ...

原作者: [db:作者] 来自: 网络 收藏 邀请

开源软件名称(OpenSource Name):

krasimir/webpack-library-starter

开源软件地址(OpenSource Url):

https://github.com/krasimir/webpack-library-starter

开源编程语言(OpenSource Language):

JavaScript 61.8%

开源软件介绍(OpenSource Introduction):

Webpack library starter

Webpack based boilerplate for producing libraries (Input: ES6/TypeScript, Output: universal library)

Features

  • Webpack 5 based.
  • ES6 or TypeScript as a source.
  • Exports in a umd format so your library works everywhere.
  • Test setup with Jest.

Process

ES6/TypeScript source files
       |
       |
    webpack
       |
       +--- babel
       |
  ready to use
     library
  in umd format

Have in mind that you have to build your library before publishing. The files under the lib folder are the ones that should be distributed.

Getting started

  1. Setting up the name of your library
  • Open webpack.config.js file and change the value of libraryName variable.
  • Open package.json file and change the value of main property so it matches the name of your library.
  1. Build your library
  • Run yarn install (recommended) or npm install to get the project's dependencies
  • Run yarn build to produce minified version of your library.
  1. Development mode
  • Run yarn dev. This command will generate a non-minified version of your library and will run a watcher so you get the compilation on file change.
  1. Running the tests
  • Run yarn test

Scripts

  • yarn build - produces production version of your library under the lib folder
  • yarn build-amd - produces an AMD version that works with RequireJS
  • yarn dev - produces development version of your library and runs a watcher
  • yarn dev-amd - produces an AMD development version of your library and runs a watcher
  • yarn test - well ... it runs the tests :)
  • yarn test-watch - same as above but in a watch mode

Readings

Misc

An example of using dependencies that shouldn’t be resolved by webpack, but should become dependencies of the resulting bundle

In the following example we are excluding React and Lodash:

{
  devtool: 'source-map',
  output: {
    path: '...',
    libraryTarget: 'umd',
    library: '...'
  },
  entry: '...',
  ...
  externals: {
    react: 'react'
    // Use more complicated mapping for lodash.
    // We need to access it differently depending
    // on the environment.
    lodash: {
      commonjs: 'lodash',
      commonjs2: 'lodash',
      amd: '_',
      root: '_'
    }
  }
}



鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
aspnet/LibraryManager发布时间:2022-08-14
下一篇:
testing- · GitHub发布时间:2022-08-14
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap