Thursday, 16 March 2017

Unexpected token from react syntax in a Docker container

I'm aware that several babel-* modules are required with the appropriate loader(s) in a build or bundler tool in order for the react syntax to be transpiled properly and to not error on compilation at runtime.

How is this achieved in Docker? Currently my DockerFile looks like:

FROM node:6.9.1 ADD package.json /tmp/package.json RUN cd /tmp && npm install RUN npm i -g babel-core \ babel-cli \ babel-preset-es2015 \ babel-preset-stage-0 \ babel-preset-stage-1 \ babel-preset-stage-2 \ babel-preset-stage-3 \ babel-preset-react \ babel-plugin-transform-async-to-generator \ babel-plugin-transform-async-to-module-method \ babel-plugin-transform-class-constructor-call \ babel-plugin-transform-class-properties \ babel-plugin-transform-decorators \ babel-plugin-transform-do-expressions \ babel-plugin-transform-exponentiation-operator \ babel-plugin-transform-export-extensions \ babel-plugin-transform-function-bind \ babel-plugin-transform-object-rest-spread \ babel-plugin-transform-react-jsx \ babel-plugin-transform-react-jsx-source \ babel-polyfill \ babel-relay-plugin \ babel-relay-plugin-loader \ babel-runtime RUN mkdir -p /opt/project && cp -a /tmp/node_modules /opt/project WORKDIR /opt/project

and docker-compose.yml:

web: build: ./ command: make web links: - db ports: - '5000:80' volumes: - ./:/opt/project

It still errors with the first < inside ReactDom



via lxm7

No comments:

Post a Comment