Skip to content

Commit

Permalink
Merge pull request #11 from homer0/homer0_fixCSSRuleForSSR
Browse files Browse the repository at this point in the history
Remove the listener that updates the CSS rules
  • Loading branch information
Leonardo Apiwan committed Apr 17, 2018
2 parents 0335a5b + 9fea6af commit 62c60e8
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 31 deletions.
16 changes: 3 additions & 13 deletions src/plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,6 @@ class ProjextReactPlugin {
* @type {string}
*/
this.scssRulesEvent = 'webpack-scss-rules-configuration';
/**
* The name of the reducer event the service will listen in order to intercept the rules for
* css files and update them.
* @type {string}
*/
this.cssRulesEvent = 'webpack-css-rules-configuration';
/**
* The name of the reducer event the service will listen in order to intercept the rules for
* fonts files, and if the target implements SSR, update them.
Expand Down Expand Up @@ -98,10 +92,6 @@ class ProjextReactPlugin {
events.on(this.scssRulesEvent, (rules, params) => (
this.updateStylesRules(rules, params.target, app.get('targets'))
));
// Add the listener for the CSS files rules event.
events.on(this.cssRulesEvent, (rules, params) => (
this.updateStylesRules(rules, params.target, app.get('targets'))
));
// Add the listener for the font files rules event.
events.on(this.fontsRulesEvent, (rules, params) => (
this.updateFontsRules(rules, params.target, app.get('targets'))
Expand Down Expand Up @@ -160,9 +150,9 @@ class ProjextReactPlugin {
return currentRules;
}
/**
* This method gets called when projext reduces the stylesheet (for both SCSS and CSS) rules of a
* target. It validates the target settings, and if the target implements SSR, it adds the
* `include` setting on the rule for the SSR targets directories.
* This method gets called when projext reduces the SCSS rules of a target. It validates the
* target settings, and if the target implements SSR, it adds the `include` setting on the rule
* for the SSR targets directories.
* @param {Array} currentRules The list of fonts rules for the webpack configuration.
* @param {Target} target The target information.
* @param {Targets} targets The targets service, to get the SSR targets information.
Expand Down
34 changes: 16 additions & 18 deletions tests/plugin.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ describe('plugin:projextReact/main', () => {
expect(sut).toBeInstanceOf(ProjextReactPlugin);
expect(sut.jsRulesEvent).toBe('webpack-js-rules-configuration');
expect(sut.scssRulesEvent).toBe('webpack-scss-rules-configuration');
expect(sut.cssRulesEvent).toBe('webpack-css-rules-configuration');
expect(sut.fontsRulesEvent).toBe('webpack-fonts-rules-configuration');
expect(sut.imagesRulesEvent).toBe('webpack-images-rules-configuration');
expect(sut.targetEventName).toBe('webpack-browser-development-configuration');
Expand All @@ -37,7 +36,6 @@ describe('plugin:projextReact/main', () => {
const expectedEvents = [
'webpack-js-rules-configuration',
'webpack-scss-rules-configuration',
'webpack-css-rules-configuration',
'webpack-fonts-rules-configuration',
'webpack-images-rules-configuration',
'webpack-browser-development-configuration',
Expand Down Expand Up @@ -396,7 +394,7 @@ describe('plugin:projextReact/main', () => {
// When
sut = new ProjextReactPlugin();
sut.register(app);
[,, [, reducer]] = events.on.mock.calls;
[, [, reducer]] = events.on.mock.calls;
result = reducer(currentRules, { target });
// Then
expect(result).toEqual(currentRules);
Expand Down Expand Up @@ -526,7 +524,7 @@ describe('plugin:projextReact/main', () => {
// When
sut = new ProjextReactPlugin();
sut.register(app);
[,, [, reducer]] = events.on.mock.calls;
[, [, reducer]] = events.on.mock.calls;
result = reducer(currentRules, { target });
// Then
expect(result).toEqual(expectedRules);
Expand Down Expand Up @@ -555,7 +553,7 @@ describe('plugin:projextReact/main', () => {
// When
sut = new ProjextReactPlugin();
sut.register(app);
[,,, [, reducer]] = events.on.mock.calls;
[,, [, reducer]] = events.on.mock.calls;
result = reducer(currentRules, { target });
// Then
expect(result).toEqual(currentRules);
Expand Down Expand Up @@ -584,7 +582,7 @@ describe('plugin:projextReact/main', () => {
// When
sut = new ProjextReactPlugin();
sut.register(app);
[,,, [, reducer]] = events.on.mock.calls;
[,, [, reducer]] = events.on.mock.calls;
result = reducer(currentRules, { target });
// Then
expect(result).toEqual(currentRules);
Expand Down Expand Up @@ -616,7 +614,7 @@ describe('plugin:projextReact/main', () => {
// When
sut = new ProjextReactPlugin();
sut.register(app);
[,,, [, reducer]] = events.on.mock.calls;
[,, [, reducer]] = events.on.mock.calls;
result = reducer(currentRules, { target });
// Then
expect(result).toEqual(currentRules);
Expand Down Expand Up @@ -648,7 +646,7 @@ describe('plugin:projextReact/main', () => {
// When
sut = new ProjextReactPlugin();
sut.register(app);
[,,, [, reducer]] = events.on.mock.calls;
[,, [, reducer]] = events.on.mock.calls;
result = reducer(currentRules, { target });
// Then
expect(result).toEqual(currentRules);
Expand Down Expand Up @@ -698,7 +696,7 @@ describe('plugin:projextReact/main', () => {
// When
sut = new ProjextReactPlugin();
sut.register(app);
[,,, [, reducer]] = events.on.mock.calls;
[,, [, reducer]] = events.on.mock.calls;
result = reducer(currentRules, { target });
// Then
expect(result).toEqual(expectedRules);
Expand Down Expand Up @@ -748,7 +746,7 @@ describe('plugin:projextReact/main', () => {
// When
sut = new ProjextReactPlugin();
sut.register(app);
[,,, [, reducer]] = events.on.mock.calls;
[,, [, reducer]] = events.on.mock.calls;
result = reducer(currentRules, { target });
// Then
expect(result).toEqual(expectedRules);
Expand Down Expand Up @@ -777,7 +775,7 @@ describe('plugin:projextReact/main', () => {
// When
sut = new ProjextReactPlugin();
sut.register(app);
[,,,, [, reducer]] = events.on.mock.calls;
[,,, [, reducer]] = events.on.mock.calls;
result = reducer(currentRules, { target });
// Then
expect(result).toEqual(currentRules);
Expand Down Expand Up @@ -806,7 +804,7 @@ describe('plugin:projextReact/main', () => {
// When
sut = new ProjextReactPlugin();
sut.register(app);
[,,,, [, reducer]] = events.on.mock.calls;
[,,, [, reducer]] = events.on.mock.calls;
result = reducer(currentRules, { target });
// Then
expect(result).toEqual(currentRules);
Expand Down Expand Up @@ -870,7 +868,7 @@ describe('plugin:projextReact/main', () => {
// When
sut = new ProjextReactPlugin();
sut.register(app);
[,,,, [, reducer]] = events.on.mock.calls;
[,,, [, reducer]] = events.on.mock.calls;
result = reducer(currentRules, { target });
// Then
expect(result).toEqual(currentRules);
Expand Down Expand Up @@ -920,7 +918,7 @@ describe('plugin:projextReact/main', () => {
// When
sut = new ProjextReactPlugin();
sut.register(app);
[,,,, [, reducer]] = events.on.mock.calls;
[,,, [, reducer]] = events.on.mock.calls;
result = reducer(currentRules, { target });
// Then
expect(result).toEqual(expectedRules);
Expand Down Expand Up @@ -970,7 +968,7 @@ describe('plugin:projextReact/main', () => {
// When
sut = new ProjextReactPlugin();
sut.register(app);
[,,,, [, reducer]] = events.on.mock.calls;
[,,, [, reducer]] = events.on.mock.calls;
result = reducer(currentRules, { target });
// Then
expect(result).toEqual(expectedRules);
Expand Down Expand Up @@ -1001,7 +999,7 @@ describe('plugin:projextReact/main', () => {
// When
sut = new ProjextReactPlugin();
sut.register(app);
[,,,,, [, reducer]] = events.on.mock.calls;
[,,,, [, reducer]] = events.on.mock.calls;
result = reducer(targetConfig, { target });
// Then
expect(result).toEqual(targetConfig);
Expand Down Expand Up @@ -1043,7 +1041,7 @@ describe('plugin:projextReact/main', () => {
// When
sut = new ProjextReactPlugin();
sut.register(app);
[,,,,, [, reducer]] = events.on.mock.calls;
[,,,, [, reducer]] = events.on.mock.calls;
result = reducer(targetConfig, { target });
// Then
expect(result).toEqual(expectedConfig);
Expand Down Expand Up @@ -1091,7 +1089,7 @@ describe('plugin:projextReact/main', () => {
// When
sut = new ProjextReactPlugin();
sut.register(app);
[,,,,, [, reducer]] = events.on.mock.calls;
[,,,, [, reducer]] = events.on.mock.calls;
result = reducer(targetConfig, { target });
// Then
expect(result).toEqual(expectedConfig);
Expand Down

0 comments on commit 62c60e8

Please sign in to comment.