Skip to content
This repository has been archived by the owner on Aug 5, 2020. It is now read-only.

Commit

Permalink
Refactor out shared webpack.config.js file. (#1193)
Browse files Browse the repository at this point in the history
* Add snapshot tests for Webpack configuration. (#1188)

* Add snapshot tests for Webpack configuration.

Change default test runner options. Existing options were only useful
for CI, and had negative effects on local development (including
continually updating snapshot tests).

* Update snapshots with new test names.

* Use self-documenting jest argument

* Search/replace system-specific paths in test.

* Refactor out shared Webpack config. (#1190)

* Separate client config from shared.

* Separate server config from shared.

* Remove preOverwrites and shared Webpack config.

* Remove CSS loader options from server build.

* Remove UniversalWebpackConfigurator type.

* Refactor out LoaderOptionsPlugin (deprecated).

This is a breaking change, necessary for upcoming ExtractCssChunks work.
postcss config is now done through postcss.config.js.

* add support for async server plugin (#1191)

* Try disabling caching

* skip build for tests
  • Loading branch information
threehams authored Jun 4, 2018
1 parent 619e8cc commit 5a025bf
Show file tree
Hide file tree
Showing 21 changed files with 1,944 additions and 574 deletions.
4 changes: 2 additions & 2 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,8 @@ jobs:
- attach_workspace:
at: ~/gluestick

- checkout
- run: yarn install:yarn
- run: yarn run test --coverage

- store_artifacts:
Expand Down Expand Up @@ -188,8 +190,6 @@ workflows:
branches:
ignore: staging
- test:
requires:
- build
filters:
branches:
ignore: staging
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,4 @@ _book/

# Gluestick uses yarn at the moment
package-lock.json
yarn-error.log
13 changes: 2 additions & 11 deletions docs/configuration/Plugins.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,13 +62,10 @@ it: `<type>.js` so it can be: `config.js`, `runtime.js`, `server.js`.
__IMPORTANT__: GlueStick won't transpile your plugin, thus it's up to you to transpile it using, for instance, `babel` or `typescript`.

## Config plugin
Must export a function that returns an object with `preOverwrites` and/or `postOverwrites`.
Must export a function that returns an object with `postOverwrites`.
```
module.exports = (options, { logger }) => {
return {
preOverwrites: {
sharedWebpackConfig: config => config,
},
postOverwrites: {
gluestickConfig: config => config,
clientWebpackConfig: config => config,
Expand All @@ -77,8 +74,7 @@ module.exports = (options, { logger }) => {
};
};
```
The exported function is a factory for two groups of overwrites: `preOverwrites` and `postOverwrites`.
This factory function accepts options that are defined in the plugins declaration file inside the project,
The `postOverwrites` factory function accepts options that are defined in the plugins declaration file inside the project,
by default `src/gluestick.plugins.js`. The second argument is an object with utilities provided by
gluestick:
- `logger` - logger instance
Expand All @@ -91,11 +87,6 @@ gluestick:
- `requireWithInterop` - require and normalize module using `getDefaultExport`
- `getDefaultExport` - normalize CJS and ESM exported value

`preOverwrites` are executed before specific configs are prepared. This is the place for modification,
for example aliases, which can define if file from import is external or not.
- `sharedWebpackConfig: config => config` - accepts a shared webpack config and
must return a valid webpack config which will be the base for both the client and server configs

`postOverwrites` are executed after every config is prepared, so modifications to configs will
go directly to webpack compiler. Modification done here won't be taken into considiration by
uniwersal-webpack. This is the place for isomorphic-like things.
Expand Down
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"install:yarn": "yarn install && yarn run build && yarn run yarn:install && lerna bootstrap --concurrency=1",
"install:yarn:ci": "yarn install --frozen-lockfile && yarn run build && yarn run yarn:install:ci && lerna bootstrap --concurrency=1",
"clean": "lerna clean --yes",
"test": "jest --bail --no-cache -i",
"test": "jest",
"test:watch": "jest --watch",
"test-coverage": "npm run test -- --coverage",
"lint": "eslint ./packages",
Expand Down Expand Up @@ -55,7 +55,8 @@
"mkdirp": "0.5.1",
"node-fetch": "^1.7.1",
"prettier": "^1.5.3",
"rimraf": "2.6.1"
"rimraf": "2.6.1",
"traverse": "0.6.6"
},
"jest": {
"notify": true,
Expand Down
4 changes: 0 additions & 4 deletions packages/gluestick/jest.js

This file was deleted.

14 changes: 0 additions & 14 deletions packages/gluestick/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@
"bugs": "https://github.com/TrueCar/gluestick/issues",
"license": "MIT",
"scripts": {
"lint": "eslint src",
"debug": "node --inspect --debug-brk ./node_modules/.bin/jest -i --env ./test/jestEnvironmentNodeDebug.js"
},
"keywords": [
"react",
Expand Down Expand Up @@ -93,7 +91,6 @@
"http-proxy-middleware": "0.17.4",
"ignore-loader": "0.1.2",
"inquirer": "3.2.0",
"jest": "20.0.4",
"lru-cache": "4.1.1",
"mkdirp": "0.5.1",
"node-fetch": "^1.7.1",
Expand All @@ -119,16 +116,5 @@
"webpack-dev-middleware": "^1.11.0",
"webpack-hot-middleware": "^2.18.2",
"webpack-node-externals": "1.7.2"
},
"jest": {
"roots": [
"src"
],
"setupFiles": [
"./jest.js"
],
"transformIgnorePatterns": [
"node_modules/(?!gluestick*)"
]
}
}
Loading

0 comments on commit 5a025bf

Please sign in to comment.