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
To begin, you'll need to install loader-example:
$ npm install loader-example --save-devThen 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.
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]: ''
})
]
};[ example outline text ]
webpack.config.js
// Example setup here..file.ext
// Source code here...bundle.js
// Bundle code here...Please take a moment to read our contributing guidelines if you haven't yet done so.