https://github.com/sectsect/modernizr-loader
Get your modernizr build bundled with webpack
https://github.com/sectsect/modernizr-loader
modenizer webpack5
Last synced: about 1 month ago
JSON representation
Get your modernizr build bundled with webpack
- Host: GitHub
- URL: https://github.com/sectsect/modernizr-loader
- Owner: sectsect
- License: mit
- Created: 2020-10-31T09:00:21.000Z (over 5 years ago)
- Default Branch: main
- Last Pushed: 2023-04-22T17:01:48.000Z (about 3 years ago)
- Last Synced: 2026-01-30T12:40:05.305Z (4 months ago)
- Topics: modenizer, webpack5
- Language: JavaScript
- Homepage: https://www.npmjs.com/package/@sect/modernizr-loader
- Size: 1.38 MB
- Stars: 3
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# @sect/modernizr-loader
[](https://badge.fury.io/js/%40sect%2Fmodernizr-loader) [](http://opensource.org/licenses/MIT)
[](https://nodei.co/npm/@sect/modernizr-loader/)
Get your Modernizr build bundled with webpack.
This Repos forked from [peerigon/modernizr-loader](https://github.com/peerigon/modernizr-loader).
## Features
- Support webpack 5
## Install
```
$ npm install --save-dev modernizr @sect/modernizr-loader json-loader
```
## Initialization
You have to create a `.modernizrrc` configuration file and put your modernizr stuff in it. Like so
```json
// .modernizrrc
{
"minify": true,
"options": [
"setClasses"
],
"feature-detects": []
}
```
Full list of supported **"options"** and **"feature-detects"** can be found in Modernizr [config-all.json](https://github.com/Modernizr/Modernizr/blob/master/lib/config-all.json).
### Webpack config
[Documentation: Using loaders](https://webpack.js.org/configuration/module/#rule-use)
Put the following code to your webpack config file:
```js
const path = require('path');
module.exports = {
module: {
rules: [
{
test: /\.modernizrrc.js$/,
use: [ '@sect/modernizr-loader' ]
},
{
test: /\.modernizrrc(\.json)?$/,
use: [ '@sect/modernizr-loader', 'json-loader' ]
}
]
},
resolve: {
alias: {
modernizr$: path.resolve(__dirname, "path/to/.modernizrrc")
}
}
}
```
### Usage
Now you are able to import your custom Modernizr build as a module throughout your application like so:
```js
import Modernizr from 'modernizr';
if (!Modernizr.promises) {
// ...
}
```
See the [Modernizr documentation](https://modernizr.com/docs) for all available options.
## Changelog
See [CHANGELOG](https://github.com/sectsect/modernizr-loader/blob/master/CHANGELOG.md) file.
## License
See [LICENSE](https://github.com/sectsect/modernizr-loader/blob/master/LICENSE) file.