diff --git a/jest.json b/jest.json index 9aed4d910f8a5d20d1679326a477877fda79ca17..d635140982349d0f2b6e906c1b113cdc4ab04b88 100644 --- a/jest.json +++ b/jest.json @@ -8,7 +8,7 @@ "coverageDirectory": "<rootDir>/coverage", "coverageReporters": ["html", "lcov"], "moduleNameMapper": { - "\\.css$": "<rootDir>/__mocks__/css.js" + "\\.s?css$": "<rootDir>/__mocks__/css.js" }, "setupFiles": [ "<rootDir>/setupJest.js" diff --git a/package.json b/package.json index f1a34227e48d59f1e2a5f5ddae9f196a8fccabe4..f0a6eec10933b8b789d5efccf052bb3537069d40 100644 --- a/package.json +++ b/package.json @@ -7,14 +7,16 @@ "dist" ], "scripts": { + "clean": "rm -rf ./dist", "lint": "node_modules/.bin/eslint ./ && node_modules/.bin/sass-lint -v ./src/styles/**/* && node ./scripts/i18n-lint.js", "server": "node_modules/.bin/http-server", "test": "npm run build && npm run lint && npm run size && jest -c jest.json", "test:watch": "jest -c jest.json --watch", "build": "webpack --mode=production", "build:dev": "webpack --mode=development", + "build:es": "mkdir -p dist/es && cp -r src dist/es && babel dist/es -d dist/es", "build:watch": "webpack --watch --mode=development", - "prepublishOnly": "rm -rf ./dist && npm run build", + "prepublishOnly": "npm run clean && npm run build:es && npm run build", "size": "size-limit", "start": "npm run build:dev && concurrently \"npm run build:watch\" \"npm run server -- -p 4444\"", "server:json": "node ./scripts/json-server/server.js >> ./scripts/json-server/json-server.log" @@ -48,8 +50,6 @@ "node-sass": "^4.9.2", "openseadragon": "^2.4.0", "prop-types": "^15.6.2", - "react": "^16.8.3", - "react-dom": "^16.8.3", "react-full-screen": "^0.2.4", "react-i18next": "^10.2.0", "react-mosaic-component": "^2.1.0", @@ -65,6 +65,7 @@ "uuid": "^3.3.2" }, "devDependencies": { + "@babel/cli": "^7.2.3", "@babel/core": "^7.2.0", "@babel/plugin-transform-runtime": "^7.3.4", "@babel/preset-env": "^7.3.1", @@ -95,7 +96,9 @@ "jsdom": "14.0.0", "json-server": "^0.14.2", "puppeteer": "^1.12.0", + "react": "^16.8.3", "react-dev-utils": "^8.0.0", + "react-dom": "^16.8.3", "redux-mock-store": "^1.5.1", "sass-lint": "^1.12.1", "size-limit": "^0.21.1", @@ -104,5 +107,9 @@ "terser-webpack-plugin": "^1.2.1", "webpack": "^4.29.0", "webpack-cli": "^3.1.2" + }, + "peerDependencies": { + "react": "^16.8.3", + "react-dom": "^16.8.3" } } diff --git a/scripts/i18n-lint.js b/scripts/i18n-lint.js index 946189fa476c934958e06579c4f1363c91e27b1c..e61701bd558b45300f5d1a5694fd71c715fb0d04 100644 --- a/scripts/i18n-lint.js +++ b/scripts/i18n-lint.js @@ -3,7 +3,7 @@ const fs = require('fs'); const chalk = require('chalk'); // eslint-disable-line import/no-extraneous-dependencies const { log } = console; -const globOpts = { cwd: 'locales' }; +const globOpts = { cwd: 'src/locales' }; const defaultLocaleFile = 'en/translation.json'; const files = glob.sync('**/translation.json', globOpts); const normalizedFiles = {}; @@ -37,7 +37,7 @@ function missingKeys(arr1, arr2) { } files.forEach((fileName) => { - const fileContent = fs.readFileSync(`locales/${fileName}`); + const fileContent = fs.readFileSync(`src/locales/${fileName}`); normalizedFiles[fileName] = Object.keys(JSON.parse(fileContent.toString()).translation); }); diff --git a/src/components/App.js b/src/components/App.js index 8e2d936ddb7e49a4c230c3f25cb011f08ac54b90..37891710b845cafa3c06d8918f3babf31cf5c28e 100644 --- a/src/components/App.js +++ b/src/components/App.js @@ -5,6 +5,7 @@ import Fullscreen from 'react-full-screen'; import { I18nextProvider } from 'react-i18next'; import i18n from '../i18n'; import WorkspaceArea from '../containers/WorkspaceArea'; +import '../styles/index.scss'; /** * This is the top level Mirador component. diff --git a/src/i18n.js b/src/i18n.js index 4aeb94a674904a8c4e0e986d90bba1b1e238c6ca..9c8cd98b73b2da13d2c6223799709ef9fbbcce5e 100644 --- a/src/i18n.js +++ b/src/i18n.js @@ -1,7 +1,7 @@ import i18n from 'i18next'; import { initReactI18next } from 'react-i18next'; -import de from '../locales/de/translation.json'; -import en from '../locales/en/translation.json'; +import de from './locales/de/translation.json'; +import en from './locales/en/translation.json'; // Load translations for each language diff --git a/src/init.js b/src/init.js index eac97062dc1f52cd36fd9f3d53852fff3fa7e119..30ccb0096723584417f8bf53fec673e1e2cb9869 100644 --- a/src/init.js +++ b/src/init.js @@ -1,5 +1,4 @@ import MiradorViewer from './lib/MiradorViewer'; -import './styles/index.scss'; /** * Default Mirador instantiation diff --git a/locales/de/translation.json b/src/locales/de/translation.json similarity index 100% rename from locales/de/translation.json rename to src/locales/de/translation.json diff --git a/locales/en/translation.json b/src/locales/en/translation.json similarity index 100% rename from locales/en/translation.json rename to src/locales/en/translation.json