B
B
be_a_man2020-05-12 07:30:31
npm
be_a_man, 2020-05-12 07:30:31

How to build a module for NPM?

There is a class (client js) with a dependency, abstractly, MyPackage.js

import dependence from 'dependence'

export default class MyPackage {
    constructor(el) {
        this.el = el
        this.dependence = dependence
    }
}


also css(MyPackage.sass in my case)
.my-package
    color: red


Structure
src
--| MyPackage.js
--| MyPackage.sass
    
demo
--| index.html
--| index.js
    --| import MyPackage from '../src/MyPackage.js'
    --| import '../src/MyPackage.sass'
    --| new MyPackage()
        
package.json
webpack.config.js

I use webpack for development, demo folder

1. What files do I need to give to NPM? MyPackage.min.js and MyPackage.min.css?
2. How to set up webpack? Different configs for dev and build?
3. Run through webpack/babel export default class MyPackage will then work with import?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vladimir Korotenko, 2020-05-12
@firedragon

Take a look
https://github.com/vkorotenko/kickout-ads

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question