customize-cra
Advanced tools
Comparing version 0.2.10 to 0.2.11
95
index.js
@@ -93,3 +93,3 @@ const flow = require("lodash.flow"); | ||
const useEslintRc = () => config => { | ||
const useEslintRc = configFile => config => { | ||
const eslintRule = config.module.rules.filter( | ||
@@ -101,2 +101,4 @@ r => r.use && r.use.some(u => u.options && u.options.useEslintrc !== void 0) | ||
eslintRule.use[0].options.ignore = true; | ||
eslintRule.use[0].options.configFile = configFile; | ||
delete eslintRule.use[0].options.baseConfig; | ||
@@ -168,40 +170,45 @@ | ||
mode === "prod" && process.env.GENERATE_SOURCEMAP !== "false"; | ||
const lessRegex = /\.less$/; | ||
const lessModuleRegex = /\.module\.less$/; | ||
const localIdentName = loaderOptions.localIdentName || "[path][name]__[local]--[hash:base64:5]"; | ||
const lessLoader = [ | ||
mode === "dev" | ||
? require.resolve("style-loader") | ||
: { | ||
loader: require("mini-css-extract-plugin").loader, | ||
options: Object.assign( | ||
{}, | ||
shouldUseRelativeAssetPaths ? { publicPath: "../../" } : undefined | ||
) | ||
}, | ||
{ | ||
loader: require.resolve("css-loader"), | ||
options: { importLoaders: 2 } | ||
}, | ||
{ | ||
loader: require.resolve("postcss-loader"), | ||
options: { | ||
ident: "postcss", | ||
plugins: () => [ | ||
require("postcss-flexbugs-fixes"), | ||
require("postcss-preset-env")({ | ||
autoprefixer: { | ||
flexbox: "no-2009" | ||
}, | ||
stage: 3 | ||
}) | ||
], | ||
sourceMap: shouldUseSourceMap | ||
const getLessLoader = (cssOptions) => { | ||
return [ | ||
mode === "dev" | ||
? require.resolve("style-loader") | ||
: { | ||
loader: require("mini-css-extract-plugin").loader, | ||
options: Object.assign( | ||
{}, | ||
shouldUseRelativeAssetPaths ? { publicPath: "../../" } : undefined | ||
) | ||
}, | ||
{ | ||
loader: require.resolve("css-loader"), | ||
options: cssOptions | ||
}, | ||
{ | ||
loader: require.resolve("postcss-loader"), | ||
options: { | ||
ident: "postcss", | ||
plugins: () => [ | ||
require("postcss-flexbugs-fixes"), | ||
require("postcss-preset-env")({ | ||
autoprefixer: { | ||
flexbox: "no-2009" | ||
}, | ||
stage: 3 | ||
}) | ||
], | ||
sourceMap: shouldUseSourceMap | ||
} | ||
}, | ||
{ | ||
loader: require.resolve("less-loader"), | ||
options: Object.assign(loaderOptions, { | ||
source: shouldUseSourceMap | ||
}) | ||
} | ||
}, | ||
{ | ||
loader: require.resolve("less-loader"), | ||
options: Object.assign(loaderOptions, { | ||
source: shouldUseSourceMap | ||
}) | ||
} | ||
]; | ||
]; | ||
}; | ||
@@ -213,5 +220,15 @@ const loaders = config.module.rules.find(rule => Array.isArray(rule.oneOf)) | ||
loaders.splice(loaders.length - 1, 0, { | ||
test: /\.less$/, | ||
use: lessLoader, | ||
test: lessRegex, | ||
exclude: lessModuleRegex, | ||
use: getLessLoader({ | ||
importLoaders: 2 | ||
}), | ||
sideEffects: mode === "prod" | ||
}, { | ||
test: lessModuleRegex, | ||
use: getLessLoader({ | ||
importLoaders: 2, | ||
modules: true, | ||
localIdentName: localIdentName | ||
}) | ||
}); | ||
@@ -218,0 +235,0 @@ |
{ | ||
"name": "customize-cra", | ||
"version": "0.2.10", | ||
"version": "0.2.11", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "repository": "arackaf/customize-cra", |
@@ -136,5 +136,6 @@ # customize-cra | ||
### useEslintRc() | ||
### useEslintRc(configFile) | ||
Causes your .eslintrc file to be used, rather than the config CRA ships with. | ||
`configFile` is an optional parameter that allows to specify the exact path to the ESLint configuration file. | ||
@@ -338,2 +339,2 @@ ### enableEslintTypescript() | ||
``` | ||
``` |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
17797
6
282
339