Skip to content

Shows how to setup a webpack-plugin/loader project including a simple loader implementation

License

Notifications You must be signed in to change notification settings

Legends/loader-example

Repository files navigation

npm node deps tests cover chat size

loader-example

Follow the steps to create a boilerplate project for writing webpack loaders/plugins

1.) Yarn init -y
2.) Install the package first: yarn add --dev @webpack-contrib/defaults
3.) Add the default command to package.json if not generated by the installation already (windows):

  scripts:{
   "default" : "webpack-defaults"
  }

4.) lastly execute:

   execute:  yarn default

Getting Started

To begin, you'll need to install loader-example:

$ npm install loader-example --save-dev

Then add the loader to your webpack config. For example:

Then add the plugin to your webpack config. For example:

file.ext

import file from 'file.ext';

webpack.config.js

module.exports = {
  module: {
    rules: [
      {
        test: /.ext$/,
        use: [
          {
            loader: `loaderexample-loader`,
            options: { ...options },
          },
        ],
      },
    ],
  },
};

webpack.config.js

module.exports = {
  plugins: [
    new `LoaderExample`Plugin(options)
  ]
}

And run webpack via your preferred method.

Options

[option]

Type: [type|other-type] Default: [type|null]

[ option description ]

webpack.config.js

module.exports = {
  module: {
    rules: [
      {
        loader: `loaderexample-loader`,
        options: {
          [option]: '',
        },
      },
    ],
  },
};

webpack.config.js

module.exports = {
  plugins: [
    new `LoaderExample`Plugin({
      [option]: ''
    })
  ]
};

Examples

[ example outline text ]

webpack.config.js

// Example setup here..

file.ext

// Source code here...

bundle.js

// Bundle code here...

Contributing

Please take a moment to read our contributing guidelines if you haven't yet done so.

CONTRIBUTING

License

MIT

About

Shows how to setup a webpack-plugin/loader project including a simple loader implementation

Resources

License

Contributing

Stars

Watchers

Forks

Releases

No releases published

Sponsor this project

Packages

No packages published