1.16.0 • Published 4 years ago

rocket-starter v1.16.0

Weekly downloads
3
License
ISC
Repository
-
Last release
4 years ago

Rocket Starter

This is the simplest way to make webpack config with many default settings. This config-generator include modules and features:

  • Webpack 4+, Webpack-dev-server
  • Support React, Angular 2+, Vue
  • TypeScript support
  • Babel 7, Babel-preset-env (> 5%)
  • Support build nodejs scripts with nodemon and livereload
  • Dotenv support
  • React optimizations
  • Flow
  • Write file webpack plugin (in dev mode)
  • Copy Webpack Plugin
  • ESLint
  • Templates: HTML/Jade/Handlebars,nunjucks
  • CSS: CSS/SASS/LESS + Postcss
  • Postcss: Autoprefixer, Mqpacker, Lost, Instagram filters, Rucksack
  • CSS Modules support
  • Imagemin
  • File import support: Markdown, Video, Audio, Fonts, SVG, Script, Shaders etc
  • SVG + SVGO
  • Uglifyjs (terser)
  • Hard Source Plugin (in production mode)
  • Generate stats.json (in production mode)
  • SEO Optimizations
  • Bundle Analyzer
  • Isomorphic compile support (include isomorphic styles, isomorphic dynamic imports, @loadable)
  • Multi compile support
  • Vendor array splitting support (You can set dependency libraries to this array to split it on separate vendor.js file)
  • MDX files support

How it works

You have 4 compilers for your scripts

const { frontendCompiler, backendCompiler, libraryCompiler, markupCompiler } = require('rocket-starter');

all of these compilers can get options object and callback. Callback is a function that will run after your webpack config will compile. This can help you for override some properties (You can see example below).

frontendCompiler(optionsoptional, callbackoptional);

can compile any frontend application (React, TypeScript, flow, etc)

const { frontendCompiler } = require('rocket-starter');

frontendCompiler(options, webpackConfig => {
    Object.assign(finalConfig.resolve, {
        alias: // add some aliases
    });
});

backendCompiler(optionsoptional, callbackoptional);

can compile nodejs scripts. Can run nodemon.

const { backendCompiler } = require('rocket-starter');

backendCompiler(options || {
    nodemon: // path to file that will run from nodemon
}, webpackConfig => {
    Object.assign(finalConfig.resolve, {
        alias: // add some aliases
    });
});

if you need to use live-reload in nodejs project you should add

<script src="http://localhost:35729/livereload.js"></script>

libraryCompiler(libraryNameneeded, optionsoptional, callbackoptional);

can compile UMD library

const { libraryCompiler } = require('rocket-starter');

libraryCompiler('MyLib', options, webpackConfig => {
    Object.assign(finalConfig.resolve, {
        alias: // add some aliases
    });
});

markupCompiler(pathsneeded, optionsoptional, callbackoptional);

can compile markup (HTML, handlebars, jade, nunjucks)

const { markupCompiler } = require('rocket-starter');

markupCompiler(
    './src/**/*.{html,hbs,jade,njk}', // supported Glob format
     options,
     webpackConfig => {
         Object.assign(finalConfig.resolve, {
             alias: // add some aliases
         });
    });

analyzerCompiler(optionsoptional, callbackoptional);

compile your application and run webpack-bundle-analyzer

const { analyzerCompiler } = require('rocket-starter');

analyzerCompiler(options); //analyzerPort by default 8888

multiCompiler(configArrayneeded);

Multi compilation

let { multiCompiler, frontendCompiler, libraryCompiler, backendCompiler } = require('rocket-starter');

multiCompiler([
    {
        compiler: backendCompiler,
        config: {
            src: './backend/src/index.js',
            dist: './backend/dist'
        }
    },
    {
        compiler: frontendCompiler,
        config: {
            src: './client/src/index.jsx',
            dist: './client/dist',
            banner: true,
            styles: 'style.css'
        }
    },
    {
        compiler: libraryCompiler,
        libraryName: 'MyLib',
        config: {
            src: './library/src/index.js',
            dist: './library/dist',
            write: true,
            html: false
        }
    }
]);

isomorphicCompiler(configArrayneeded);

Compile isomorphic app

const { isomorphicCompiler, backendCompiler, frontendCompiler } = require('rocket-starter');

isomorphicCompiler([
    {
        compiler: backendCompiler,
        config: {
            src: 'backend/src/index.jsx'
        }
    },
    {
        compiler: frontendCompiler,
        config: {
            src: 'client/src/index.jsx',
            dist: 'backend/dist',
            write: true,
            html: false,
            onlyWatch: true
        }
    }
]);

Default Options:

{
    dist: 'dist',
    src: 'src/index',
    url: '/',
    debug: false, // Activate debug mode in all plugins or loaders
    stats: false, // Generate stats webpack file
    write: false, // Write files to HDD after changes (watch mode)
    inline: true, // Convert images, fonts, svg to base64
    analyzerPort: false, //port number, for example: 8888
    server: {
        browserSyncPort: false, // run with browser-sync
        port: 3000,
        host: 'localhost'
    }
}

All Options

{
    dist: 'dist',
    src: 'src/index',
    url: '/',
    debug: false, // Activate debug mode in all plugins or loaders
    stats: false, // Generate stats webpack file
    write: false, // Write files to HDD after changes (watch mode)
    inline: true, // Convert images, fonts, svg to base64
    analyzerPort: false, //port number, for example: 8888
    vendor: ['react', 'react-dom'],
    server: {
        browserSyncPort: false, // run with browser-sync
        port: 3000,
        host: 'localhost'
    },
    // secondary properties
    nodemon: path to nodemon run file (only for backendCompiler)
    dotenv: 'path_to_dotend or put .env file to your project',
    version: false, // You can add version to script's filenames
    styles: String, // You can extract CSS styles from scripts, or disable it - set false
    html: { // CopyWebpackPlugin. You can also add array for multi-pages support
        title: String,
        favicon: ...,
        version: Boolean,
        template: String, path to file
    }
    banner: String, // You can set banner in the head of scripts
    global: { // DefinePlugin activate
        var: 'var1'
    },
    copy: {from: ... to: ...} || [] || {files: [], opts: {}}
}

TypeScript activation:

You can run it with NODE_ENV=production - it is active uglifier.

If you want a styles extraction you need to set styles: 'mystyle.css'

If you don't need to extract styles to css file in production version you can set styles: false

"copy" is activate CopyWebpackPlugin and we can use default syntax but we can set files and opts. Opts is second parameter in this plugin.

"write" will force Webpack to save file in HDD after each update webpack watcher / dev-server

You can add eslint config. Just add eslintrc.js in your main (project) dir.

You can add postcss config. Just add postcss.config.js in your main (project) dir.

Add .flowconfig to root folder and that activation flow-type checking

@babel/core@babel/plugin-proposal-class-properties@babel/plugin-proposal-pipeline-operator@babel/plugin-proposal-do-expressions@babel/plugin-proposal-logical-assignment-operators@babel/plugin-proposal-optional-chaining@babel/plugin-proposal-nullish-coalescing-operator@babel/plugin-proposal-decorators@babel/plugin-proposal-object-rest-spread@babel/plugin-syntax-dynamic-import@babel/plugin-transform-flow-comments@babel/plugin-transform-react-constant-elements@babel/plugin-transform-react-inline-elements@loadable/babel-plugin@babel/preset-env@babel/preset-react@becklyn/typescript-error-formatter@loadable/webpack-plugin@mdx-js/loaderautoprefixerbabel-eslintbabel-loaderbabel-plugin-transform-react-pure-class-to-functionbabel-plugin-transform-react-remove-prop-typesbrowser-syncbrowser-sync-webpack-plugincase-sensitive-paths-webpack-plugincircular-dependency-pluginclean-webpack-plugincopy-webpack-plugincss-loadercss-mqpackercssnanodeep-extenddotenv-webpackeslinteslint-config-react-appeslint-formatter-friendlyeslint-formatter-prettyeslint-loadereslint-plugin-compateslint-plugin-flowtypeeslint-plugin-importeslint-plugin-jsx-a11yeslint-plugin-reacteslint-plugin-react-hooksextract-loaderfs-extrafile-loaderfind-free-portflow-babel-webpack-pluginget-port-syncglobgutilhandlebarshandlebars-loaderhtml-loaderhtml-webpack-pluginisomorphic-style-loaderimagemin-mozjpegimagemin-webpack-pluginimports-loaderinspectpackjson-loaderlessless-loaderlostmarkdown-loadermini-css-extract-pluginmomentnode-loadernode-sasscross-envnodemon-webpack-pluginnunjucksnunjucks-isomorphic-loaderoptimize-css-assets-webpack-pluginpostcss-instagrampostcss-loaderpugpug-loaderrucksack-csssass-loaderscript-loadershader-loadersocket.iosource-mapstyle-loadersvg-inline-loadersvgosvgo-loaderterserts-loadertypescript@teamsupercell/typings-for-css-modules-loaderuglifyjs-webpack-pluginurl-loadervalid-typesvue-loadervue-template-compilerwebpackwebpack-bundle-analyzerwebpack-dev-serverwebpack-graphql-loaderwebpack-livereload-pluginwebpack-stats-pluginwebpackbarwrite-file-webpack-pluginyargs
1.16.0

4 years ago

1.15.6

5 years ago

1.15.4

5 years ago

1.15.5

5 years ago

1.15.3

5 years ago

1.15.2

5 years ago

1.15.1

5 years ago

1.15.0

5 years ago

1.12.2

5 years ago

1.12.1

5 years ago

1.12.0

5 years ago

1.11.10

5 years ago

1.11.9

5 years ago

1.11.8

5 years ago

1.11.7

5 years ago

1.11.6

5 years ago

1.11.5

5 years ago

1.11.0

5 years ago

1.10.0

5 years ago

1.9.1

5 years ago

1.9.0

5 years ago

1.8.2

5 years ago

1.8.1

5 years ago

1.8.0

5 years ago

1.7.5

5 years ago

1.7.0

5 years ago

1.6.1

5 years ago

1.6.0

5 years ago

1.5.2

5 years ago

1.5.0

5 years ago

1.2.1

5 years ago

1.2.0

5 years ago

1.1.4

5 years ago

1.1.3

5 years ago

1.1.2

5 years ago

1.1.1

6 years ago

1.1.0

6 years ago

1.0.0

6 years ago