{"id":19631397,"url":"https://github.com/andersaloof/modernizr-auto-loader","last_synced_at":"2025-10-12T05:35:20.667Z","repository":{"id":57300505,"uuid":"59647006","full_name":"andersaloof/modernizr-auto-loader","owner":"andersaloof","description":"A webpack loader to automatically build a custom version of Modernizr.","archived":false,"fork":false,"pushed_at":"2019-11-06T21:08:52.000Z","size":8,"stargazers_count":7,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-05-20T21:29:17.726Z","etag":null,"topics":["customizr","loader","modernizr","webpack"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/andersaloof.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-05-25T08:50:48.000Z","updated_at":"2017-12-26T07:55:56.000Z","dependencies_parsed_at":"2022-09-09T12:41:47.284Z","dependency_job_id":null,"html_url":"https://github.com/andersaloof/modernizr-auto-loader","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/andersaloof/modernizr-auto-loader","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andersaloof%2Fmodernizr-auto-loader","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andersaloof%2Fmodernizr-auto-loader/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andersaloof%2Fmodernizr-auto-loader/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andersaloof%2Fmodernizr-auto-loader/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/andersaloof","download_url":"https://codeload.github.com/andersaloof/modernizr-auto-loader/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andersaloof%2Fmodernizr-auto-loader/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":259804841,"owners_count":22913901,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["customizr","loader","modernizr","webpack"],"created_at":"2024-11-11T12:08:52.612Z","updated_at":"2025-10-12T05:35:15.630Z","avatar_url":"https://github.com/andersaloof.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# modernizr-auto-loader for webpack\n\nThis loader uses [Modernizr/customizr](https://github.com/Modernizr/customizr) to \"...crawl your project for Modernizr test references and save out a minified, uglified, customized version using only the tests you've used in your JavaScript or (S)CSS.\".\n\nIt outputs a self executing module, which automatically loads your custom modernizr build, and it also updates on all webpack rebuilds. Yay! Automagic!\n\n## Installation\n\n```\n$ npm install --save-dev modernizr-auto-loader\n```\n\n## Usage\n\n### .modernizr-autorc configuration file\n\n[Documentation: Using loaders](http://webpack.github.io/docs/using-loaders.html)\n\nCreate a `.modernizr-autorc` configuration file (in valid JSON format), preferably in your project root, and put *your* customizr config details in it. , like this:\n\n```javascript\n// .modernizr-autorc\n{\n  \"option\": \"value\"\n}\n```\n\nThe default configuration used by this loader, which will be extended by your custom config is:\n```javascript\n// default config\n{\n\t\"options\": [\"setClasses\", \"addTest\", \"html5printshiv\", \"testProp\", \"fnBind\"],\n\t\"files\": {\n\t\t\"src\": [\"**[^node_modules]/**/*.{js,css,scss}\"]\n\t}\n}\n```\n\n(See the [Customizr documentation](https://modernizr.com/docs) for all available options.)\n\nAs specified in the default config, **modernizr-auto-loader** crawls **all** *js/css/scss* files except files in *node_modules* (pattern `**[^node_modules]/**/*.{js,css,scss}`) by default, so it's recommended to specify your own file patterns to speed things up, or in worst case, have **customizr** abort due to too many open files.\n\nThe following config makes customizer only traverse an assets folder, looking for js/jsx/css/scss files.\n```javascript\n// .modernizr-autorc\n{\n  \"files\": {\n    \"src\": [\n      \"assets/**/*.{js,jsx,css,scss}\"\n    ]\n  }\n}\n```\n\nIf you want **modernizr-auto-loader** to only run once on startup of the webpack build, you can by adding *runOnce: true* to the configuration file, like this:\n\n```javascript\n// .modernizr-autorc\n{\n  \"files\": {\n    \"src\": [\n      \"assets/**/*.{js,jsx,css,scss}\"\n    ]\n  },\n  \"runOnce\": true\n}\n```\n\n### webpack configuration\n\nAdjust your webpack config to trigger **modernizr-auto-loader** on build. If you didn't put your config in the root folder, resolve the path relative to your webpack config.\n\n```javascript\nmodule.exports = {\n  module: {\n    loaders: [\n      {\n        test: /\\.modernizr-autorc$/,\n        loader: \"modernizr-auto-loader\"\n      }\n    ]\n  },\n  resolve: {\n    alias: {\n      modernizr$: path.resolve(__dirname, \".modernizr-autorc\")\n    }\n  }\n}\n```\n\n### JS integration\n\nFinally, require the configuration file (with a full relative path) somewhere in your source file (typically your entry point) or even simpler, just require 'modernizr'.\n\n```javascript\n// require config file with relative path (makes ESLint module/file resolvers happy)\nrequire(\"relative/path/to/.modernizr-autorc\");\n\n// OR, require modernizr\nrequire(\"modernizr\"); // es5\n```\n\nSince Modernizr is a global, you can also test for features in your JS files, like this:\n\n```javascript\nif (!Modernizr.promises) {\n    // ...\n}\n```\n\nIf you're using ESLint, make sure Modernizr is added as a global to prevent *no-undef* errors.\n\n## Inspired by\n\nThis loader is inspired by [gulp-modernizr](https://github.com/doctyper/gulp-modernizr) and [modernizr-loader](https://github.com/peerigon/modernizr-loader).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fandersaloof%2Fmodernizr-auto-loader","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fandersaloof%2Fmodernizr-auto-loader","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fandersaloof%2Fmodernizr-auto-loader/lists"}