Skip to content

Commit

Permalink
Use webpack alias instead of symlink hack
Browse files Browse the repository at this point in the history
  • Loading branch information
lydell committed Dec 3, 2018
1 parent 0273662 commit 8442bb9
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 11 deletions.
4 changes: 2 additions & 2 deletions djedi-react/.babelrc
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
"env": {
"development": {
"presets": ["next/babel"],
"plugins": ["djedi-react/babel-plugin"]
"plugins": ["./babel-plugin"]
},
"production": {
"presets": ["next/babel"],
"plugins": ["djedi-react/babel-plugin"]
"plugins": ["./babel-plugin"]
},
"test": {
"presets": [
Expand Down
16 changes: 9 additions & 7 deletions djedi-react/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1055,13 +1055,6 @@ docker run --rm -it -v /absolute/path/to/djedi-cms/djedi-react:/code -v /code/no

### Notes

#### npm install

`npm start` creates `node_modules/djedi-react` – a symlink to this directory.
This is so that the example app can use `import "djedi-react"`. However,
`npm install` gets confused by that symlink. If you need to install or remove
dependencies, run `npm run fix-install` first to remove the symlink.

#### Test changes in example

If you make changes to the library and want to try them out on
Expand All @@ -1077,6 +1070,15 @@ npm start # But kill old server first :)
docker-compose restart node
```

This is because the example runs against the built code, as an integration test.
If you get tired of rebuilding, you can run the example against the source code
instead:

```
DJEDI_REACT_DIR=src npm start
DJEDI_REACT_DIR=src docker-compose up -d node
```

#### docker and permissions

docker runs as root, so files that it creates are owned by root. If you run
Expand Down
19 changes: 19 additions & 0 deletions djedi-react/next.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
const path = require("path");

// No Next.js config is required to use djedi-react, but the example app needs
// to resolve `import "djedi-react"` to local directories in the repo.
module.exports = {
webpack: config => ({
...config,
resolve: {
...config.resolve,
alias: {
...config.resolve.alias,
"djedi-react": path.resolve(
__dirname,
process.env.DJEDI_REACT_DIR || ""
),
},
},
}),
};
3 changes: 1 addition & 2 deletions djedi-react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@
"react"
],
"scripts": {
"fix-install": "rm -f node_modules/djedi-react",
"start": "ln -fsrn . node_modules/djedi-react && next",
"start": "next",
"watch": "jest --watchAll",
"eslint": "eslint .",
"eslint:fix": "eslint . --fix",
Expand Down
1 change: 1 addition & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ services:
- ./djedi-react/:/code
- /code/node_modules
environment:
- DJEDI_REACT_DIR=${DJEDI_REACT_DIR:-}
- SERVER_BASE_URL=http://django:8000/djedi/api

# Piggy-backing on djedi-react’s image and node_modules to watch CoffeeScript files.
Expand Down

0 comments on commit 8442bb9

Please sign in to comment.