### Install and Run Roadhog Commands Source: https://github.com/sorrycc/roadhog/blob/master/README.md Install Roadhog globally or locally and check its version. Use 'dev' for local development, 'build' for production builds (with an option to disable compression), and 'test' for running tests. ```bash ## Install globally or locally $ npm i roadhog -g ## Check version $ roadhog -v 2.0.0 ## Local development $ roadhog dev ## Build $ roadhog build $ NO_COMPRESS=1 roadhog build ## Test $ roadhog test ``` -------------------------------- ### Configure Webpack Entry Points with Glob Source: https://github.com/sorrycc/roadhog/blob/master/README.md Specify webpack entry points using glob patterns, useful for multipage applications. This example sets all `.js` files in the `src/pages/` directory as entries. ```json "entry": "src/pages/*.js" ``` -------------------------------- ### Configure Webpack Externals in JavaScript Source: https://github.com/sorrycc/roadhog/blob/master/README.md Configure webpack's externals property using a JavaScript file (`.webpackrc.js`) for more complex logic, supporting ES6 syntax. This example prevents packing React and ReactDOM. ```javascript export default { externals: { react: 'window.React' }, } ``` -------------------------------- ### Configure Theme from File Source: https://github.com/sorrycc/roadhog/blob/master/README.md Configure the theme by providing a path to a JavaScript file that returns theme configurations. ```json "theme": "./theme-config.js" ``` -------------------------------- ### Configure Browserslist Source: https://github.com/sorrycc/roadhog/blob/master/README.md Configure browserslist targets, which are used by babel-preset-env and autoprefixer. ```json "browserslist": [ "> 1%", "last 2 versions" ] ``` -------------------------------- ### Configure Environment Variables Source: https://github.com/sorrycc/roadhog/blob/master/README.md Configure environment-specific variables for the build process. ```json "env": {} ``` -------------------------------- ### Configure Theme with Less Variables Source: https://github.com/sorrycc/roadhog/blob/master/README.md Configure the theme using Less variables. Supports direct object assignment for variables or a string path to a configuration file. ```json "theme": { "@primary-color": "#1DA57A" } ``` -------------------------------- ### Configure Environment-Specific Plugins Source: https://github.com/sorrycc/roadhog/blob/master/README.md Set environment-specific configurations, such as adding development-only Babel plugins. This allows for different build behaviors in development versus production. ```js "extraBabelPlugins": ["transform-runtime"], "env": { "development": { "extraBabelPlugins": ["dva-hmr"] } } ``` -------------------------------- ### Configure Extra Babel Includes Source: https://github.com/sorrycc/roadhog/blob/master/README.md Specify additional directories or files to be included in Babel transpilation. ```json "extraBabelIncludes": [] ``` -------------------------------- ### Configure Sass Options Source: https://github.com/sorrycc/roadhog/blob/master/README.md Configure Sass loader options. ```json "sass": {} ``` -------------------------------- ### Configure Extra Babel Presets Source: https://github.com/sorrycc/roadhog/blob/master/README.md Specify additional Babel presets to be used in the project. ```json "extraBabelPresets": [] ``` -------------------------------- ### Configure Copy Plugin Source: https://github.com/sorrycc/roadhog/blob/master/README.md Configure the copy-webpack-plugin to copy files from the public directory to the output directory. ```json "copy": [] ``` -------------------------------- ### Configure Webpack HTML Source: https://github.com/sorrycc/roadhog/blob/master/README.md Configure webpack's html-webpack-plugin settings. ```json "html": {} ``` -------------------------------- ### Configure Proxy Source: https://github.com/sorrycc/roadhog/blob/master/README.md Configure webpack's proxy settings for development server. ```json "proxy": {} ``` -------------------------------- ### Configure Extra Babel Plugins Source: https://github.com/sorrycc/roadhog/blob/master/README.md Specify additional Babel plugins to be used in the project. ```json "extraBabelPlugins": [] ``` -------------------------------- ### Configure Manifest Plugin Source: https://github.com/sorrycc/roadhog/blob/master/README.md Configure webpack's manifest plugin settings. ```json "manifest": {} ``` -------------------------------- ### Configure CopyWebpackPlugin Source: https://github.com/sorrycc/roadhog/blob/master/README.md Define files to be copied during the build process. Refer to copy-webpack-plugin for item configuration details. ```markup "copy": [ { "from": "", "to": "" } ] ``` -------------------------------- ### Configure Manifest Plugin Source: https://github.com/sorrycc/roadhog/blob/master/README.md Configure the generation of manifest.json. Options are passed directly to the webpack-manifest-plugin. ```markup "manifest": { "basePath": "/app/" } ``` -------------------------------- ### Configure Webpack Hash Source: https://github.com/sorrycc/roadhog/blob/master/README.md Configure webpack's output.hashFunction property for file naming. ```json "hash": false ``` -------------------------------- ### Configure Webpack Commons Source: https://github.com/sorrycc/roadhog/blob/master/README.md Configure webpack's commons chunk plugin settings. ```json "commons": [] ``` -------------------------------- ### Configure Webpack Output Path Source: https://github.com/sorrycc/roadhog/blob/master/README.md Configure webpack's output.path property, specifying the output directory for the bundled files. ```json "outputPath": "dist" ``` -------------------------------- ### Configure HTML Webpack Plugin Source: https://github.com/sorrycc/roadhog/blob/master/README.md Configure the html-webpack-plugin to customize HTML generation. Specify a template file for your HTML. ```markup "html": { "template": "./src/index.ejs" } ``` -------------------------------- ### Configure Webpack Devtool Source: https://github.com/sorrycc/roadhog/blob/master/README.md Configure webpack's devtool property for source map generation. ```json "devtool": "source-map" ``` -------------------------------- ### Set Development Server Port Source: https://github.com/sorrycc/roadhog/blob/master/README.md Temporarily configure the development server port using environment variables. This is a common practice for managing different local development environments. ```bash # OS X, Linux $ PORT=3000 roadhog dev # Windows (cmd.exe) $ set PORT=3000&&roadhog dev # Or use cross-env for all platforms $ cross-env PORT=3000 roadhog dev ``` -------------------------------- ### Configure CommonsChunkPlugin Source: https://github.com/sorrycc/roadhog/blob/master/README.md Use this to configure webpack's CommonsChunkPlugin for code splitting. The minChunks logic can be dynamic based on page count. ```markup "commons": [ { async: '__common', children: true, minChunks(module, count) { if (pageCount <= 2) { return count >= pageCount; } return count >= pageCount * 0.5; }, }, ] ``` -------------------------------- ### Configure DefinePlugin Values Source: https://github.com/sorrycc/roadhog/blob/master/README.md Configure values to be passed to the code via webpack's DefinePlugin. Values are automatically stringified using JSON.stringify. ```json "define": { "process.env.TEST": 1, "USE_COMMA": 2, } ``` -------------------------------- ### Configure Webpack Output Public Path Source: https://github.com/sorrycc/roadhog/blob/master/README.md Configure webpack's output.publicPath property, which determines the public URL of the output directory. ```json "publicPath": "/" ``` -------------------------------- ### Configure Mock API Endpoints Source: https://github.com/sorrycc/roadhog/blob/master/README.md Define mock API endpoints in `.roadhogrc.mock.js`. Supports object and array formats for responses, omitting HTTP methods, and custom functions for dynamic responses similar to Express. ```javascript export default { // Support type as Object and Array 'GET /api/users': { users: [1,2] }, // Method like GET or POST can be omitted '/api/users/1': { id: 1 }, // Support for custom functions, the API is the same as express@4 'POST /api/users/create': (req, res) => { res.end('OK'); }, }; ``` -------------------------------- ### Configure Dev Server Proxy Source: https://github.com/sorrycc/roadhog/blob/master/README.md Configure the webpack-dev-server proxy to forward API requests to other servers. This is useful for development when the backend is on a different host. ```markup "proxy": { "/api": { "target": "http://jsonplaceholder.typicode.com/", "changeOrigin": true, "pathRewrite": { "^/api" : "" } } } ``` -------------------------------- ### Configure Webpack Extra Resolve Extensions Source: https://github.com/sorrycc/roadhog/blob/master/README.md Configure webpack's resolve.extensions property to specify additional file extensions that webpack should resolve. ```json "extraResolveExtensions": [] ``` -------------------------------- ### Configure HTML Template in Roadhog Source: https://github.com/sorrycc/roadhog/blob/master/migrate-from-1.x.md If you are using a custom `src/index.ejs` template, move it to `public/index.html` and configure the path in your `.webpackrc` or `webpack.config.js`. ```json "html": { "template": "./src/index.ejs" } ``` -------------------------------- ### Configure Webpack Alias Source: https://github.com/sorrycc/roadhog/blob/master/README.md Configure webpack's resolve.alias property to provide custom resolution for modules. ```json "alias": {} ``` -------------------------------- ### Disable CSS Modules Source: https://github.com/sorrycc/roadhog/blob/master/README.md Disable CSS Modules globally for the project. ```json "disableCSSModules": true ``` -------------------------------- ### Ignore Moment Locale Source: https://github.com/sorrycc/roadhog/blob/master/README.md Disable the inclusion of moment.js locales to reduce bundle size. ```json "ignoreMomentLocale": true ``` -------------------------------- ### Disable Dynamic Import Source: https://github.com/sorrycc/roadhog/blob/master/README.md Disable dynamic import feature in webpack. ```json "disableDynamicImport": true ``` -------------------------------- ### Disable CSS Source Map Source: https://github.com/sorrycc/roadhog/blob/master/README.md Disable the generation of CSS source maps. ```json "disableCSSSourceMap": true ``` -------------------------------- ### Configure Webpack Externals in JSON Source: https://github.com/sorrycc/roadhog/blob/master/README.md Configure webpack's externals property using a JSON file (`.webpackrc`) to prevent certain modules from being packed, such as React and ReactDOM, by specifying their global variable names. ```json { "externals": { "react": "window.React" } } ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.