Skip to content

Commit

Permalink
feat: remove the ident property from loader options (#446)
Browse files Browse the repository at this point in the history
  • Loading branch information
cap-Bernardito authored Aug 17, 2020
1 parent a043922 commit 53f678d
Show file tree
Hide file tree
Showing 7 changed files with 1 addition and 43 deletions.
9 changes: 1 addition & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,6 @@ module.exports = {
test: /\.css$/i,
loader: 'postcss-loader',
options: {
ident: 'postcss',
plugins: (loader) => [
require('postcss-import')({ root: loader.resourcePath }),
require('postcss-preset-env')(),
Expand All @@ -322,8 +321,6 @@ module.exports = {
};
```

> ⚠️ webpack requires an identifier (`ident`) in `options` when `{Function}/require` is used (Complex Options). The `ident` can be freely named as long as it is unique. It's recommended to name it (`ident: 'postcss'`)
**`webpack.config.js`**

```js
Expand All @@ -334,7 +331,6 @@ module.exports = {
test: /\.css$/i,
loader: 'postcss-loader',
options: {
ident: 'postcss',
plugins: {
'postcss-import': {},
'postcss-nested': {},
Expand Down Expand Up @@ -371,7 +367,6 @@ module.exports = {
test: /\.css$/i,
loader: 'postcss-loader',
options: {
ident: 'postcss',
plugins: {
'postcss-import': {},
'postcss-nested': {},
Expand Down Expand Up @@ -586,7 +581,7 @@ module.exports = {
### `SourceMap`

Type: `Boolean|String`
Default: `undefined`
Default: `compiler.devtool`

By default generation of source maps depends on the devtool option.
All values enable source map generation except eval and false value.
Expand Down Expand Up @@ -667,7 +662,6 @@ module.exports = {
{
loader: 'postcss-loader',
options: {
ident: 'postcss',
plugins: [require('postcss-import')(), require('stylelint')()],
},
},
Expand All @@ -694,7 +688,6 @@ module.exports = {
{
loader: 'postcss-loader',
options: {
ident: 'postcss',
plugins: [require('autoprefixer')({ ...options })],
},
},
Expand Down
9 changes: 0 additions & 9 deletions test/options/__snapshots__/config.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -54,15 +54,6 @@ exports[`Config Options should work Config - {Object}: errors 1`] = `Array []`;

exports[`Config Options should work Config - {Object}: warnings 1`] = `Array []`;

exports[`Config Options should work Config - Context - {Object} - with ident: css 1`] = `
"a { color: rgba(255, 0, 0, 1.0) }
"
`;

exports[`Config Options should work Config - Context - {Object} - with ident: errors 1`] = `Array []`;

exports[`Config Options should work Config - Context - {Object} - with ident: warnings 1`] = `Array []`;

exports[`Config Options should work Config - Context - {Object}: css 1`] = `
"a { color: rgba(255, 0, 0, 1.0) }
"
Expand Down
17 changes: 0 additions & 17 deletions test/options/config.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -131,23 +131,6 @@ describe('Config Options', () => {
expect(getErrors(stats)).toMatchSnapshot('errors');
});

it('should work Config - Context - {Object} - with ident', async () => {
const compiler = getCompiler('./css/index.js', {
ident: 'postcss',
config: {
path: 'test/fixtures/config/postcss.config.js',
ctx: { plugin: true },
},
});
const stats = await compile(compiler);

const codeFromBundle = getCodeFromBundle('style.css', stats);

expect(codeFromBundle.css).toMatchSnapshot('css');
expect(getWarnings(stats)).toMatchSnapshot('warnings');
expect(getErrors(stats)).toMatchSnapshot('errors');
});

it('should work Config – Context – Loader {Object}', async () => {
const compiler = getCompiler('./css/index.js', {
config: {
Expand Down
2 changes: 0 additions & 2 deletions test/options/parser.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ describe('Options Parser', () => {
loader: path.resolve(__dirname, '../../src'),
// eslint-disable-next-line global-require
options: {
ident: 'postcss',
// eslint-disable-next-line global-require,import/no-dynamic-require
parser: require('sugarss'),
config: false,
Expand Down Expand Up @@ -99,7 +98,6 @@ describe('Options Parser', () => {
loader: path.resolve(__dirname, '../../src'),
// eslint-disable-next-line global-require
options: {
ident: 'postcss',
// eslint-disable-next-line global-require,import/no-dynamic-require
parser: require('sugarss').parse,
config: false,
Expand Down
4 changes: 0 additions & 4 deletions test/options/plugins.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import {
describe('Options Plugins', () => {
it('should work Plugins - {Array}', async () => {
const compiler = getCompiler('./css/index.js', {
ident: 'postcss',
// eslint-disable-next-line global-require
plugins: [require('../fixtures/config/plugin')()],
});
Expand All @@ -24,7 +23,6 @@ describe('Options Plugins', () => {

it('should work Plugins - {Object}', async () => {
const compiler = getCompiler('./css/index.js', {
ident: 'postcss',
// eslint-disable-next-line global-require
plugins: require('../fixtures/config/plugin'),
});
Expand All @@ -39,7 +37,6 @@ describe('Options Plugins', () => {

it('should work Plugins - {Function} - {Array}', async () => {
const compiler = getCompiler('./css/index.js', {
ident: 'postcss',
// eslint-disable-next-line global-require
plugins: () => [require('../fixtures/config/plugin')()],
});
Expand All @@ -54,7 +51,6 @@ describe('Options Plugins', () => {

it('should work Plugins - {Function} - {Object}', async () => {
const compiler = getCompiler('./css/index.js', {
ident: 'postcss',
// eslint-disable-next-line global-require
plugins: () => require('../fixtures/config/plugin')(),
});
Expand Down
2 changes: 0 additions & 2 deletions test/options/stringifier.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ describe('Options Stringifier', () => {

it('should work Stringifier - {Object}', async () => {
const compiler = getCompiler('./css/index.js', {
ident: 'postcss',
// eslint-disable-next-line global-require
stringifier: require('sugarss'),
config: false,
Expand Down Expand Up @@ -58,7 +57,6 @@ describe('Options Stringifier', () => {

it('should emit error Stringifier', async () => {
const compiler = getCompiler('./css/index.js', {
ident: 'postcss',
// eslint-disable-next-line global-require
stringifier: 'unresolved',
config: false,
Expand Down
1 change: 0 additions & 1 deletion test/options/syntax.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ describe('Options Syntax', () => {
{
loader: path.resolve(__dirname, '../../src'),
options: {
ident: 'postcss',
// eslint-disable-next-line global-require
syntax: require('sugarss'),
config: false,
Expand Down

0 comments on commit 53f678d

Please sign in to comment.