Skip to content

New Webpack plugin and enhanced IDE autocompletion

Compare
Choose a tag to compare
@D-Pow D-Pow released this 22 May 18:06
· 140 commits to master since this release

New and improved version of mock-requests is now here!

Webpack plugin

Instead of manually changing your webpack.config.js configuration fields with the previous resolveMocks(), now you can simply plug-and-play using the bundled mock-requests/bin/MockRequestsWebpackPlugin. For example:

const MockRequestsWebpackPlugin = require('mock-requests/bin/MockRequestsWebpackPlugin');

module.exports = {
    module: {
        rules: [
            {
                test: /\.jsx?$/,
                exclude: /node_modules/,
                include: /src/,
                loader: 'babel-loader'
            },
            // ...
    },
    entry: {
        client: [ 'core-js', 'isomorphic-fetch', './src/index.js' ],
        vendor: [ 'react', 'react-dom', 'prop-types' ]
    },
    plugins: [
        new MockRequestsWebpackPlugin(
            'mocks',  // directory containing mock files
            'MockConfig.js',  // entry point for mock-requests configuration, resides within the `mocks/` directory
            process.env.MOCK === 'true',  // boolean to (de-)activate mocks, can be whatever you want
            // options, if applicable
        )
    ]
};

More options and usage examples can be seen in the ReadMe.

IDE autocompletion

MockRequests now includes enhanced IDE autocompletion and JSDoc descriptions. While seemingly trivial on the surface, this dramatically enhances the development experience by offering suggestions, descriptions, and types for all fields.