3.1.0 • Published 4 years ago

hiro-sdk-scripts v3.1.0

Weekly downloads
34
License
-
Repository
github
Last release
4 years ago

hiro-sdk-scripts

Customized react-scripts package for hiro-sdk-apps

Project setup

Prerequisites

  • node 8+
  • npm 6+

Commands

create-hiro-sdk-app

==> We should merge this command with hiro-sdk-cli init.

Initializes new HIRO Application without ejecting based on hiro-sdk-cli v1.2.2.

Usage:

  • npx --package hiro-sdk-scripts create-hiro-sdk-app 'my-app' - initialize blank my-app application.
  • npx --package hiro-sdk-scripts create-hiro-sdk-app 'my-app' -t react - initialize React my-app applicaiton.

Advanced usage:

  • npx --package hiro-sdk-scripts create-hiro-sdk-app 'my-app' -l - initialize blank my-app application and link local hiro-sdk package
  • npx --package hiro-sdk-scripts create-hiro-sdk-app 'my-app' -t react -l - initialize React my-app applicaiton and link local hiro-sdk package

Scripts

Copied from react-scripts v3.3.0 using custom configuration see Customization below.

  • npm start
  • npm run build
  • npm test
  • npm run eject

Usefull hiro-sdk command shortcuts, preventing installation of hiro-sdk-cli:

Customization

Base: react-scripts v3.3.0

env.js

  • remove regex test for prefix "REACTAPP" to allow us to use environment variables without predefined prefix.

webpack.config.prod.js

  • Disable chunks
  • Remove trailing slash from asset-manifest.json
  • extend webpack oneOf rule to embed all assets. Fixes loading issues of assets loaded by url-loader, caused by missing token.

    {
      test: [
        /\.bmp$/, 
        /\.gif$/, 
        /\.jpe?g$/, 
        /\.png$/, 
        /\.ttf$/, 
        /\.svg$/, 
        /\.woff$/, 
        /\.woff2$/, 
        /\.eot$/
      ],
      loader: require.resolve('url-loader'),
      options: {
        limit: 250000,
        name: 'static/media/[name].[hash:8].[ext]',
      },
    },