{"id":17141787,"url":"https://github.com/zmofei/grunt-staticize","last_synced_at":"2025-04-10T09:48:39.945Z","repository":{"id":17437306,"uuid":"20210755","full_name":"zmofei/grunt-staticize","owner":"zmofei","description":"staticize your website static files","archived":false,"fork":false,"pushed_at":"2019-05-01T15:10:47.000Z","size":156,"stargazers_count":17,"open_issues_count":0,"forks_count":6,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-24T08:42:36.962Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"HTML","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/zmofei.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE-MIT","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-05-27T07:19:58.000Z","updated_at":"2019-05-01T15:10:48.000Z","dependencies_parsed_at":"2022-07-26T17:02:12.891Z","dependency_job_id":null,"html_url":"https://github.com/zmofei/grunt-staticize","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zmofei%2Fgrunt-staticize","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zmofei%2Fgrunt-staticize/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zmofei%2Fgrunt-staticize/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zmofei%2Fgrunt-staticize/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zmofei","download_url":"https://codeload.github.com/zmofei/grunt-staticize/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248197433,"owners_count":21063619,"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":[],"created_at":"2024-10-14T20:27:06.692Z","updated_at":"2025-04-10T09:48:39.922Z","avatar_url":"https://github.com/zmofei.png","language":"HTML","funding_links":[],"categories":[],"sub_categories":[],"readme":"# grunt-staticize\n\n\u003e Staticize your static files.\n\n## Getting Started\nThis plugin requires Grunt `~0.4.5`\n\nIf you haven't used [Grunt](http://gruntjs.com/) before, be sure to check out the [Getting Started](http://gruntjs.com/getting-started) guide, as it explains how to create a [Gruntfile](http://gruntjs.com/sample-gruntfile) as well as install and use Grunt plugins. Once you're familiar with that process, you may install this plugin with this command:\n\n```shell\nnpm install grunt-staticize --save-dev\n```\n\nOnce the plugin has been installed, it may be enabled inside your Gruntfile with this line of JavaScript:\n\n```js\ngrunt.loadNpmTasks('grunt-staticize');\n```\n\n## The \"staticize\" task\n\n### Overview\nIn your project's Gruntfile, add a section named `staticize` to the data object passed into `grunt.initConfig()`.\n\n```js\ngrunt.initConfig({\n  staticize: {\n    targetName:{\n      rev:{  //revisioning task\n        msite:{ //target\n          'cwd':'folderPath',\n          'files': ['temp/msite/**/*.{css,js,jpg,png,gif}'],\n          'dest': 'testF_2'\n        },\n        options: {  //revisioning options\n          'encoding': 'utf8',\n          'algorithm': 'md5',\n          'length': 8\n        }\n      },\n      rep: {  //replace task\n        msite: {  //target\n          'files': ['temp/msite/*.{css,js,jade}'],\n          'assetsDirs': 'temp/msite/static/',\n          'patterns': /\\/{0,1}\\w+(\\/\\w+)*\\.\\w+/mg\n        }\n      }\n    }\n  },\n});\n```\n\n=======\n\n### Revisioning task\n\nRevisionging task is to add hash for files,like:  `/static/logo.jpg` -\u003e `/static/logo.d124da.jpg`\n\nRevisionging use field `rev` to defined.\n\n`rev` is a json type,which inclode some target,and a option\n\n```js\n//...\n  rev:{\n    targetA:{\n      //...\n    }\n    targetB:{\n      //...\n    }\n    option:{\n      //...\n    }\n  }\n//...\n``` \n#### target\n\nIn each target you need defined `files`(the files you want opration) and `dest`(where you save the new files)\n\n`dest` is optional,if you write this value,the new files will save to this folder, if you didn't write this,the old files will overwrite by the new files.\n\n#### options [optional]\n\n##### options.encoding [optional] \n\nType: `String` Default value: `utf8`\n\nthe files' encoding\n\n##### options.algorithm [optional]  \n\nType: `String` Default value: `md5`\n\nthe files hash type\n\n##### options.length [optional] \n\nType: `String` Default value: `8`\n\nthe hash length in the filename\n\n#### example\n\n```js\ngrunt.initConfig({\n  staticize: {\n    targetName:{\n      rev:{  //revisioning task\n        msite:{ //target\n          'cwd':'folderPath',\n          'files': ['temp/msite/**/*.{css,js,jpg,png,gif}'],\n          'dest': 'testF_2'\n        },\n        options: {  //revisioning options\n          'encoding': 'utf8',\n          'algorithm': 'md5',\n          'length': 8\n        }\n      }\n    }\n  },\n});\n```\n\n=====\n\n### Replace task\n\nReplace task is to replace all the resources' link url\n\nThat's say after you `/static/logo.jpg` -\u003e `/static/logo.d124da.jpg`,you can use replace task to change all the place which use this file, for example in `index.css` and `index.html` we have \n\n```css\n.logo{\n  background:url('/static/logo.jpg');\n}\n```\n\n```html\n\u003cimg src=\"/static/logo.jpg\"\u003e\n```\nafter replace task,this two file will became\n\n```css\n.logo{\n  background:url('/static/logo.d124da.jpg');\n}\n```\n\n```html\n\u003cimg src=\"/static/logo.d124da.jpg\"\u003e\n```\n\nReplace use field `rep` to defined.\n\n`rep` is a json type,which inclode some target\n\n```js\n//...\n  rep:{\n    targetA: { },\n    targetB: { }\n  }\n//...\n``` \n#### target\n\nIn each target you need defined `files`(the files you want opration) and `assetsDirs`(the static's place ) and `patterns` (which we need replace)\n\n#### example\n\n```js\ngrunt.initConfig({\n  staticize: {\n    rep: {  //replace task\n      msite: {  //target\n        'files': ['temp/msite/*.{css,js,jade}'],  //replace this files \n        'assetsDirs': 'temp/msite/static/',  //the static which files use in 'temp/msite/static/'\n        'patterns': /\\/{0,1}\\w+(\\/\\w+)*\\.\\w+/mg  //if match for example 'ad/ad.jpg','dfa/d.css' and try to replace the match based on the 'assetsDirs'\n      }\n    }\n  },\n});\n```\n\n\n======\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzmofei%2Fgrunt-staticize","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzmofei%2Fgrunt-staticize","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzmofei%2Fgrunt-staticize/lists"}