2.0.1 • Published 2 years ago

@neat-preset/babel v2.0.1

Weekly downloads
34
License
MIT
Repository
github
Last release
2 years ago

neat-presets

My highly opinionated batteries included plugin-bundle for nextjs applications

  • Babel presets for next @neat-preset/babel/next and node @neat-preset/babel/node
  • Production ready next configuration at @neat-preset/next which is including next-env, next-images and next-fonts
  • Adds dotenv loading behaviour similar to create-react-app
  • Adds global dev-expression (compiling __DEV__ to true or false based on your NODE_ENV passed to next build)
  • Includes my favorite babel plugins like babel-plugin-macros and export-syntax extensions See list below

Usage

yarn add @neat-preset/next yarn add --dev @neat-preset/next-dev @neat-preset/babel

Create a .env

NEXT_SERVER_TEST_1=ONLY_ON_SSR
NEXT_PUBLIC_TEST_1=INJECTED_BY_SSR  // available/exposed in the browser
NEXT_STATIC_TEST_1=STATIC_TEXT      // embedded in the js bundles on build time (use this in nextjs serverless mode!)

Ignore .env.local files in your .gitignore

.env.local
.env.*.local

What other env files can i use?.

Babel for Nextjs Clients

{
  "presets": [
    ["@neat-preset/babel/next", {
      "preset-env": {},
      "transform-runtime": {},
      "module-resolver": {},
      "styled-jsx": {},
      "class-properties": {}
      "optional-chaining": {}
      "styled-components": {}
    }]
  ],
  "plugins": []
}

Babel for Node

{
  "presets": [
    ["@neat-preset/babel/node", {
      "preset-env": {},
      "transform-runtime": {},
      "module-resolver": {},
      "class-properties": {}
    }]
  ],
  "plugins": []
}

next.config.js

With CSS modules and options:

// next.config.js
const withNeat = require('@neat-preset/next-dev')({
    css: {
        cssModules: true,
        cssLoaderOptions: {
            importLoaders: 1,
            localIdentName: '[local]___[hash:base64:5]',
        },
    },
})

module.exports = withNeat({
    target: 'serverless',
})

With images from a different remote or inlined images with size limit:

module.exports = require('@neat-preset/next-dev')({
    fonts: {
        assetPrefix: 'https://example.com',
        inlineImageLimit: 16384, // default is 8192
    },
})({
    target: 'serverless',
})

With fonts from a different remote or include SVG fonts:

module.exports = require('@neat-preset/next-dev')({
    fonts: {
        assetPrefix: 'https://example.com',
        enableSvg: true,
    },
})({
    target: 'serverless',
})

With Custom env variable prefixes:

module.exports = require('@neat-preset/next-dev')({
    env: {
        staticPrefix: 'NEXT_APP_STATIC_',
        publicPrefix: 'NEXT_APP_PUBLIC_',
    },
})({
    target: 'serverless',
})

License

Licensed under the MIT License, Copyright © 2019-present Richard Keil

See LICENSE for more information.

Acknowledgements

This project is standing on the shoulders of giants as it is build on top of earlier open-source work by clever folks all around the world.

Please check them out:

Included Libraries

2.0.1

2 years ago

1.10.5

2 years ago

1.10.4

2 years ago

1.10.3

2 years ago

1.10.2

2 years ago

1.10.1

3 years ago

1.10.0

3 years ago

1.9.0

3 years ago

1.8.1

3 years ago

1.8.0

3 years ago

1.7.1

3 years ago

1.7.0

3 years ago

1.6.1

3 years ago

1.6.0

3 years ago

1.5.7

3 years ago

1.5.6

3 years ago

1.5.5

4 years ago

1.5.4

4 years ago

1.5.3

4 years ago

1.5.2

4 years ago

1.5.1

4 years ago

1.5.0

4 years ago

1.4.4

4 years ago

1.4.3

4 years ago

1.4.2

4 years ago

1.4.1

4 years ago

1.4.0

4 years ago

1.3.17

4 years ago

1.3.16

4 years ago

1.3.15

4 years ago

1.3.14

4 years ago

1.3.13

4 years ago

1.3.11

4 years ago

1.3.12

4 years ago

1.3.10

4 years ago

1.3.9

4 years ago

1.3.8

4 years ago

1.3.7

4 years ago

1.3.6

4 years ago

1.3.5

4 years ago

1.3.4

4 years ago

1.3.3

4 years ago

1.3.2

4 years ago

1.3.1

4 years ago

1.3.0

4 years ago

1.2.3

4 years ago

1.2.2

4 years ago

1.2.1

4 years ago

1.2.0

4 years ago

1.1.1

4 years ago

1.1.2

4 years ago

1.1.0

4 years ago

1.0.3

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago

0.1.0

4 years ago

1.0.0

4 years ago

0.3.0

4 years ago

0.2.0

4 years ago

0.4.0

4 years ago

0.0.3

5 years ago

0.0.2

5 years ago

0.0.1

5 years ago