customize-cra
Advanced tools
Comparing version 0.2.11 to 0.2.12
32
index.js
@@ -84,2 +84,10 @@ const flow = require("lodash.flow"); | ||
const addWebpackResolve = resolve => config => { | ||
if (!config.resolve) { | ||
config.resolve = {}; | ||
} | ||
Object.assign(config.resolve, resolve); | ||
return config; | ||
} | ||
const adjustWorkbox = adjust => config => { | ||
@@ -288,2 +296,21 @@ config.plugins.forEach(p => { | ||
// This will remove the CRA plugin that prevents to import modules from | ||
// outside the `src` directory, useful if you use a different directory | ||
const removeModuleScopePlugin = () => config => { | ||
config.resolve.plugins = config.resolve.plugins.filter( | ||
p => p.constructor.name !== "ModuleScopePlugin" | ||
); | ||
return config; | ||
}; | ||
const addTslintLoader = (options) => config => { | ||
config.module.rules.unshift({ | ||
test: /\.(ts|tsx)$/, | ||
loader: require.resolve("tslint-loader"), | ||
options, | ||
enforce: "pre", | ||
}); | ||
return config; | ||
}; | ||
module.exports = { | ||
@@ -296,2 +323,3 @@ override, | ||
addWebpackAlias, | ||
addWebpackResolve, | ||
adjustWorkbox, | ||
@@ -311,3 +339,5 @@ useEslintRc, | ||
addPostcssPlugins, | ||
getBabelLoader | ||
getBabelLoader, | ||
removeModuleScopePlugin, | ||
addTslintLoader, | ||
}; |
{ | ||
"name": "customize-cra", | ||
"version": "0.2.11", | ||
"version": "0.2.12", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "repository": "arackaf/customize-cra", |
@@ -94,3 +94,3 @@ # customize-cra | ||
Overwites the `include` option for babel loader, for when you need to transpile a module in your `node_modules` folder. | ||
Overwrites the `include` option for babel loader, for when you need to transpile a module in your `node_modules` folder. | ||
@@ -150,2 +150,6 @@ ```js | ||
### addWebpackResolve(resolve) | ||
Adds the provided resolve info into webpack's resolve section. Pass an object literal with as many entries as you'd like, and the whole object will be merged in. | ||
### addBundleVisualizer(options, behindFlag = false) | ||
@@ -241,3 +245,4 @@ | ||
strictMath: true, | ||
noIeCompat: true | ||
noIeCompat: true, | ||
localIdentName: '[local]--[hash:base64:5]' // if you use CSS Modules, and custom `localIdentName`, default is '[local]--[hash:base64:5]'. | ||
}) | ||
@@ -251,2 +256,4 @@ ); | ||
`.module.less` will use CSS Modules. | ||
### disableChunk | ||
@@ -289,2 +296,10 @@ | ||
## removeModuleScopePlugin() | ||
This will remove the CRA plugin that prevents to import modules from | ||
outside the `src` directory, useful if you use a different directory. | ||
A common use case is if you are using CRA in a monorepo setup, where your packages | ||
are under `packages/` rather than `src/`. | ||
## MobX Users | ||
@@ -332,13 +347,22 @@ | ||
```js | ||
const { override, addPostcssPlugins } = require("customize-cra"); | ||
module.exports = override( | ||
addPostcssPlugins([require("postcss-px2rem")({ remUnit: 37.5 })]) | ||
); | ||
``` | ||
### addTslintLoader(loaderOptions) | ||
Need to install `ts-loader`. | ||
```js | ||
const { | ||
override, | ||
addPostcssPlugins | ||
addTslintLoader | ||
} = require("customize-cra"); | ||
module.exports = override( | ||
addPostcssPlugins([ | ||
require('postcss-px2rem')({ remUnit: 37.5 }) | ||
]), | ||
addTslintLoader(), | ||
); | ||
``` |
19417
309
363