Skip to content

Commit

Permalink
Switched to root import plugin replacing module-resolver plugin.
Browse files Browse the repository at this point in the history
  • Loading branch information
swernerx committed Jun 26, 2017
1 parent 75c97dd commit 9aea569
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 4 deletions.
5 changes: 5 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
"babel-plugin-fast-async": "^6.1.2",
"babel-plugin-lodash": "^3.2.11",
"babel-plugin-react-intl": "^2.3.1",
"babel-plugin-root-import": "^5.1.0",
"babel-plugin-syntax-dynamic-import": "^6.18.0",
"babel-plugin-transform-class-properties": "^6.24.1",
"babel-plugin-transform-object-rest-spread": "^6.23.0",
Expand Down
14 changes: 10 additions & 4 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import reactPreset from "babel-preset-react"
import flowPreset from "babel-preset-flow"

import dynamicImportPlugin from "babel-plugin-syntax-dynamic-import"
import moduleResolverPlugin from "babel-plugin-module-resolver"
import rootImportPlugin from "babel-plugin-module-resolver"
import fastAsyncPlugin from "babel-plugin-fast-async"
import classPropertiesPlugin from "babel-plugin-transform-class-properties"
import objectRestSpreadPlugin from "babel-plugin-transform-object-rest-spread"
Expand Down Expand Up @@ -36,6 +36,9 @@ export default function buildPreset(context, opts = {})
// Lodash Plugin Settings
optimizeModules: [ "lodash", "async", "rambda", "recompose" ],

//
sourceFolder: "src",

// Babel Settings
comments: false,
compact: true,
Expand Down Expand Up @@ -104,9 +107,12 @@ export default function buildPreset(context, opts = {})
plugins.push([ lodashPlugin, { id: options.optimizeModules }])

// Supports loading files in source folder without relative folders
// https://github.com/tleunen/babel-plugin-module-resolver
plugins.push([ moduleResolverPlugin, {
root: [ resolvePath(getAppRoot(), "src") ]
// https://github.com/entwicklerstube/babel-plugin-root-import
// It's better than "babel-plugin-module-resolver" as it supports a custom prefix
// so that it is clear which files are locally or from `node_modules`.
plugins.push([ rootImportPlugin, {
rootPathPrefix: "~",
rootPathSuffix: [ resolvePath(getAppRoot(), options.sourceFolder) ]
}])

// Alternative to Babel Regenerator
Expand Down

0 comments on commit 9aea569

Please sign in to comment.