Gathering detailed insights and metrics for happy-mock-webpack-plugin
Gathering detailed insights and metrics for happy-mock-webpack-plugin
npm install happy-mock-webpack-plugin
Typescript
Module System
Node Version
NPM Version
69.6
Supply Chain
98.2
Quality
75.2
Maintenance
100
Vulnerability
99.6
License
JavaScript (100%)
Total Downloads
962
Last Day
5
Last Week
14
Last Month
22
Last Year
111
5 Commits
2 Watching
1 Branches
1 Contributors
Minified
Minified + Gzipped
Latest Version
0.0.14
Package Id
happy-mock-webpack-plugin@0.0.14
Unpacked Size
12.53 kB
Size
5.63 kB
File Count
14
NPM Version
5.6.0
Node Version
8.11.3
Cumulative downloads
Total Downloads
Last day
0%
5
Compared to previous day
Last week
0%
14
Compared to previous week
Last month
1,000%
22
Compared to previous month
Last year
-17.8%
111
Compared to previous year
1
3
This plugin provides a simple way to mock your data via webpack and webapck-dev-server. You can easily mock your own data with just a little configuration.
Note that currently this plugin only supports
GET
method.
1npm install happy-mock-webpack-plugin
In webpack config file, add this plugin instance:
1const HappyMockMockPlugin = require('happy-mock-webpack-plugin') 2const path = require('path') 3 4module.exports = { 5 // other configs 6 plugins: [ 7 // other plugins... 8 new HappyMockMockPlugin({ 9 root: path.resolve(__dirname, 'mock'), 10 lazy: true, 11 autoRefresh: true 12 }) 13 ] 14}
directory example:
- src
- app.js
- mock
- user
- profile.json
- orders.js
- menu.js
The directory path is the request url, for example, if you use axios
, axios.get('/user/profile')
will lead you to /mock/user/profile.json
. There're some mock examples
This file exports a function, it takes request
and response
as args, these two are from webpack-dev-server
which are express
request and response objects. You can return different content via
different request params.
1module.exports = (request, response) => { 2 // handle request ... 3 // modify response ... 4 return { 5 data: [] 6 } 7}
1{ 2 "name": "John Doe" 3} 4
1module.exports = { 2 items: [], 3 from: 'xx' 4} 5
Other files will be returned as it is.
root
String
The directory that you want to put your mock files to. It must be an absolute path
lazy
Boolean
If it's true, the file will be loaded only when there's request to it. In this case, the request takes longer but app starts faster than the other case.
If it's false, the app will get all mock files and cache it, so the app starts slower, but the request is faster via the cache.
autoRefresh
Boolean
If you set it to true
, every time you change your mock files, the browser will automatically refresh to make sure you can get the lateset data. If it's false
, you need to refresh the browser by yourself to make it.
Note: this field works only when
lazy=true
, otherwise the cache will take priority and you need to restart the app to get the updated mock files.
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
0 existing vulnerabilities detected
Reason
license file detected
Details
Reason
Found 0/5 approved changesets -- score normalized to 0
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no SAST tool detected
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
project is not fuzzed
Details
Reason
security policy file not detected
Details
Reason
branch protection not enabled on development/release branches
Details
Score
Last Scanned on 2025-02-03
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More