I am working on an angular project and have decided to use a boilerplate for it. Here is the link to the boilerplate: https://github.com/jakemmarsh/angularjs-gulp-browserify-boilerplate
The problem i am facing is that i am unable to add any new moudle.
e.g i wanted to add ngCart via npm. I have installed it but it is not accessible in the code.
`import angular from 'angular';
// angular modules
import constants from './constants';
import onConfig from './on_config';
import onRun from './on_run';
import 'angular-ui-router';
import 'ngCart'; //this doesn't import it
import './templates';
import './filters';
import './controllers';
import './services';
import './directives';
// create and bootstrap application
const requires = [
'ui.router',
'ngCart',
'templates',
'app.filters',
'app.controllers',
'app.services',
'app.directives'
];
// mount on window for testing
window.app = angular.module('app', requires);
angular.module('app').constant('AppSettings', constants);
angular.module('app').config(onConfig);
angular.module('app').run(onRun);
angular.bootstrap(document, ['app'], {
strictDi: true
});
My package.json is
{
"name": "angularjs-gulp-browserify-boilerplate",
"version": "1.7.1",
"author": "Jake Marsh <jakemmarsh#gmail.com>",
"description": "Boilerplate using AngularJS, SASS, Gulp, and Browserify while also utilizing best practices.",
"repository": {
"type": "git",
"url": "https://github.com/jakemmarsh/angularjs-gulp-browserify-boilerplate.git"
},
"license": "MIT",
"keywords": [
"express",
"gulp",
"browserify",
"angular",
"sass",
"karma",
"jasmine",
"protractor",
"boilerplate"
],
"private": false,
"engines": {
"node": "~4.2.x"
},
"scripts": {
"dev": "cross-env NODE_ENV=development ./node_modules/.bin/gulp dev",
"build": "cross-env NODE_ENV=production ./node_modules/.bin/gulp prod",
"deploy": "cross-env NODE_ENV=production ./node_modules/.bin/gulp deploy",
"test": "cross-env NODE_ENV=test ./node_modules/.bin/gulp test",
"protractor": "cross-env NODE_ENV=test ./node_modules/.bin/gulp protractor",
"unit": "cross-env NODE_ENV=test ./node_modules/.bin/gulp unit"
},
"dependencies": {
"cross-env": "^3.1.1",
"ngCart": "1.0.0"
},
"devDependencies": {
"angular": "^1.5.0",
"angular-mocks": "^1.3.15",
"angular-ui-router": "^0.3.1",
"babel-core": "^6.3.26",
"babel-eslint": "^7.0.0",
"babel-preset-es2015": "^6.3.13",
"babel-register": "^6.5.2",
"babelify": "^7.2.0",
"brfs": "^1.2.0",
"browser-sync": "^2.7.6",
"browserify": "^13.0.0",
"browserify-istanbul": "^2.0.0",
"browserify-ngannotate": "^2.0.0",
"bulk-require": "^1.0.0",
"bulkify": "^1.1.1",
"debowerify": "^1.3.1",
"del": "^2.1.0",
"envify": "^3.4.0",
"ngCart": "^1.0.0",
"eslint": "3.7.1",
"express": "^4.13.3",
"gulp": "^3.9.0",
"gulp-angular-templatecache": "^2.0.0",
"gulp-autoprefixer": "^3.1.0",
"gulp-changed": "^1.0.0",
"gulp-eslint": "^3.0.1",
"gulp-gzip": "^1.2.0",
"gulp-if": "^2.0.0",
"gulp-imagemin": "^3.0.3",
"gulp-notify": "^2.0.0",
"gulp-protractor": "^3.0.0",
"gulp-rename": "^1.2.0",
"gulp-sass": "^2.0.4",
"gulp-sass-glob": "^1.0.6",
"gulp-sourcemaps": "^1.6.0",
"gulp-streamify": "^1.0.2",
"gulp-uglify": "^2.0.0",
"gulp-util": "^3.0.1",
"imagemin-pngcrush": "^5.0.0",
"isparta": "^4.0.0",
"karma": "^1.3.0",
"karma-browserify": "^5.0.2",
"karma-chrome-launcher": "^2.0.0",
"karma-coverage": "douglasduteil/karma-coverage#next",
"karma-firefox-launcher": "^1.0.0",
"karma-jasmine": "^1.0.2",
"karma-sauce-launcher": "^1.0.0",
"merge-stream": "^1.0.0",
"pretty-hrtime": "^1.0.1",
"run-sequence": "^1.1.5",
"tiny-lr": "^0.2.1",
"uglifyify": "^3.0.1",
"vinyl-buffer": "^1.0.0",
"vinyl-source-stream": "^1.1.0",
"watchify": "^3.7.0"
}
}
ngCart does not have a main key in its package.json, nor an index.js at its root, so import can not know what to import. So you need to be a little more explicit in your import statement.
try to replace
import 'ngCart'; //this doesn't import it
by
import 'ngCart/dist/ngCart'; //this should do it ;)
Related
three version:^0.140.2
#react-three/fiber version:^8.0.19
#react-three/drei version:^9.11.0
node version:14.18.13
npm (or yarn) version: 1.22.17 (yarn)
react version:17.0.1
react-dom version:17.0.1
Problem description:
Implementing react three drei above my NextJS app getting an error when go to the page which import react three drei, like the following:
./node_modules/#react-three/drei/web/Html.js:3:0 Module not found: Can't resolve 'react-dom/client' Import trace for requested module: ./node_modules/#react-three/drei/index.js ./components/Model3D/ThreeDModel.js ./pages/new.js
Expected:
I go to 'new' page, then I can load 3d model with .glb format from HTML input tag using useGLTF
Relevant Code:
import React from 'react'
import { useGLTF } from '#react-three/drei/core/useGLTF'
import { OrbitControls } from '#react-three/drei'
import { parseImgUrl } from 'utils/common'
const Model1 = ({ threeDUrl }) => {
const loadedGltf = useGLTF(parseImgUrl(threeDUrl), true)
return (
<>
<primitive object={loadedGltf.scene} dispose={null} />
<OrbitControls />
<ambientLight />
</>
)
}
export { Model1 }
Suggested Solution:
At this time, I think root cause of the error is that my react three drei which I used don't supported react#17.0.1. I expected that previous react three drei version support react#17.0.1 then really wonder what specified version that support react#17.0.1 or maybe the error was caused by other things. Thank you for your support, that's always my pleasure.
This is the entire dependencies within package.json
{
"name": "paras-v2-landing",
"version": "0.1.0",
"private": true,
"type": "module",
"scripts": {
"dev": "next dev",
"dev:testnet": "PORT=8081 dotenv -e .env.testnet next dev",
"dev:mainnet": "PORT=8082 dotenv -e .env.mainnet next dev",
"build": "next build",
"start": "next start",
"lint": "next lint",
"format": "prettier --write .",
"prettier-check": "prettier --check .",
"prepare": "husky install"
},
"dependencies": {
"#draft-js-plugins/anchor": "^4.1.1",
"#draft-js-plugins/buttons": "^4.0.0",
"#draft-js-plugins/divider": "^4.1.1",
"#draft-js-plugins/editor": "^4.0.0",
"#draft-js-plugins/focus": "^4.1.0",
"#draft-js-plugins/image": "^4.0.0",
"#draft-js-plugins/inline-toolbar": "^4.1.0",
"#draft-js-plugins/linkify": "^4.1.0",
"#draft-js-plugins/static-toolbar": "^4.0.0",
"#draft-js-plugins/video": "^4.1.0",
"#react-three/drei": "^9.11.0",
"#react-three/fiber": "^8.0.19",
"#sentry/nextjs": "^6.12.0",
"#tailwindcss/line-clamp": "^0.3.1",
"axios": "^0.21.0",
"blurhash": "^1.1.3",
"cachios": "^3.0.0",
"capitalize": "^2.0.4",
"cids": "^1.1.5",
"compressorjs": "^1.0.7",
"croppie": "^2.6.5",
"draft-js": "^0.11.7",
"file-type": "^16.5.3",
"generate-avatar": "^1.4.10",
"javascript-time-ago": "^2.3.2",
"js-base64": "^3.5.2",
"js-cookie": "^2.2.1",
"jsbi": "^3.1.4",
"near-api-js": "^0.42.0",
"next": "^12.1.6",
"postcss": "^8.4.12",
"query-string": "^7.0.1",
"react": "^18.1.0",
"react-awesome-animated-number": "^1.0.6",
"react-blurhash": "^0.1.3",
"react-card-flip": "^1.1.5",
"react-content-loader": "^6.0.3",
"react-custom-scrollbars": "^4.2.1",
"react-dom": "^18.1.0",
"react-fast-marquee": "^1.1.3",
"react-google-recaptcha": "^2.1.0",
"react-hamburgers": "^1.0.0",
"react-hook-form": "^6.10.0",
"react-horizontal-scrolling-menu": "^2.7.0",
"react-infinite-scroll-component": "^5.1.0",
"react-intl": "^5.9.2",
"react-linkify": "^1.0.0-alpha",
"react-responsive-carousel": "^3.2.23",
"react-share": "^4.3.1",
"react-slick": "^0.28.1",
"react-tooltip": "^4.2.17",
"recharts": "^2.1.9",
"slick-carousel": "^1.8.1",
"swr": "^1.2.2",
"three": "^0.140.2",
"three-stdlib": "^2.10.1",
"uuid": "^8.3.2",
"zustand": "^3.1.3"
},
"devDependencies": {
"#next/bundle-analyzer": "^12.1.4",
"autoprefixer": "^10.4.4",
"dotenv-cli": "^4.1.1",
"eslint": "^7.30.0",
"eslint-config-next": "^11.0.1",
"eslint-config-prettier": "8.3.0",
"eslint-plugin-react-hooks": "^4.2.0",
"husky": "^7.0.0",
"lint-staged": "^11.1.2",
"postcss-import": "^13.0.0",
"postcss-preset-env": "^6.7.0",
"prettier": "2.4.1",
"pretty-quick": "^3.1.2",
"tailwindcss": "^3.0.23"
},
"license": "GPL-3.0",
"husky": {
"hooks": {
"pre-commit": "lint-staged"
}
},
"lint-staged": {
"*.{js,jsx}": [
"eslint --fix",
"git add"
],
"*.{html,css,less,ejs}": [
"git add"
]
}
}
Finally after many steps of troubleshooting rails is rendering our NavBar component, but not the base App component where everything is imported. Wondering what I might need to consider if there's a gem version not working properly like uglifier? Out of my two react_components rendered it finds the NavBar fine.
index.html.erb:
<%= react_component('NavBar', { isUserAuthed: #is_user_authed }) %>
<%= react_component('App') %>
App.jsx:
import React from "react";
import 'fontsource-roboto';
import Home from "../components/Home";
class App extends React.Component {
render() {
return (
<>
<Home/>
</>
)
}
}
export default App;
application.js:
// app/javascript/packs/application.js
import Rails from "#rails/ujs"
import Turbolinks from "turbolinks"
import * as ActiveStorage from "#rails/activestorage"
import "channels"
var componentRequireContext = require.context("components", true);
var ReactRailsUJS = require("react_ujs");
ReactRailsUJS.useContext(componentRequireContext);
Rails.start()
Turbolinks.start()
ActiveStorage.start()
package.json:
{
"name": "my-webpack-project",
"private": true,
"dependencies": {
"#babel/plugin-proposal-class-properties": "^7.16.5",
"#babel/plugin-proposal-decorators": "^7.16.4",
"#babel/plugin-proposal-object-rest-spread": "^7.16.0",
"#babel/plugin-proposal-private-methods": "^7.16.0",
"#babel/plugin-proposal-private-property-in-object": "^7.16.0",
"#babel/plugin-syntax-dynamic-import": "^7.8.3",
"#babel/plugin-syntax-jsx": "^7.16.0",
"#babel/plugin-transform-destructuring": "^7.16.0",
"#babel/plugin-transform-regenerator": "^7.16.0",
"#babel/plugin-transform-runtime": "^7.16.4",
"#babel/preset-env": "^7.16.5",
"#date-io/date-fns": "^2.9.1",
"#date-io/moment": "^2.9.0",
"#jest/globals": "^26.3.0",
"#material-ui/core": "^4.11.0",
"#material-ui/icons": "^4.9.1",
"#material-ui/pickers": "^3.2.10",
"#rails/actioncable": "^6.1.4-1",
"#rails/activestorage": "^6.1.4-1",
"#rails/ujs": "^6.1.4-1",
"#rails/webpacker": "5.4.3",
"babel-plugin-transform-react-remove-prop-types": "^0.4.24",
"caniuse-lite": "^1.0.30001249",
"clsx": "^1.1.1",
"date-fns": "^2.16.1",
"fetch-mock": "^9.10.6",
"fontsource-roboto": "^3.0.3",
"html-webpack-plugin": "^4.5.2",
"isomorphic-fetch": "^2.2.1",
"jquery": "^3.5.0",
"leaflet": "^1.6.0",
"lodash": "^4.17.20",
"mapbox-gl": "^1.8.1",
"moment": "^2.27.0",
"node": "16",
"node-fetch": "^2.6.0",
"npm": "^6.14.7",
"popper.js": "^1.16.1",
"postcss-cssnext": "^3.1.0",
"prop-types": "^15.7.2",
"query-string": "^6.13.1",
"react": "^16.13.1",
"react-dom": "^16.13.1",
"react-leaflet": "^2.6.1",
"react-password-strength": "^2.4.0",
"react-router-dom": "^5.1.2",
"react_ujs": "^2.6.1",
"recharts": "^2.0.9",
"sass": "^1.37.5",
"turbolinks": "^5.2.0",
"webpack": "^4.46.0",
"webpack-cli": "^3.3.12",
"webpack-dev-server": "^3",
"uglify-js": "git://github.com/mishoo/UglifyJS2#harmony"
},
"devDependencies": {
"#babel/core": "^7.16.5",
"#webpack-cli/generators": "^2.4.1",
"autoprefixer": "^10.4.0",
"babel-loader": "^8.2.3",
"babel-plugin-transform-class-properties": "^6.24.1",
"babel-preset-es2015": "^6.24.1",
"babel-preset-react": "^6.24.1",
"css-loader": "^5.2.7",
"jest": "^26.0.1",
"mini-css-extract-plugin": "^1.6.2",
"node-sass": "^7.0.0",
"post-loader": "^2.0.0",
"postcss": "^8.4.4",
"sass-loader": "^10.2.0",
"style-loader": "^2.0.0"
},
"version": "1.0.0",
"description": "My webpack project",
"scripts": {
"build": "webpack --mode=production --node-env=production",
"build:dev": "webpack --mode=development",
"build:prod": "webpack --mode=production --node-env=production",
"watch": "webpack --watch",
"serve": "webpack serve"
}
}
Do you have this in your config?
$ tail -n 12 webpack.config.js
})
],
module: {
rules: [
{
test: /\.(js|jsx|ts|tsx|)$/,
exclude: /node_modules/,
use: ['babel-loader'],
}
]
}
}
https://github.com/reactjs/react-rails/blob/master/README.md#3-install-react-and-some-other-required-npm-packages
Update the Babel configuration in the package.json file:
"babel": {
"presets": [
- "./node_modules/shakapacker/package/babel/preset.js"
+ "./node_modules/shakapacker/package/babel/preset.js",
+ "#babel/preset-react"
]
},
This could be a very easy question, however I've not been able to find the answer for it anywhere.
How do I use a default locale with react-intl? Specifying a default message every time gets really messy. The way that I'm doing it at the moment doesn't seem to pick up the default message when the browser uses a locale that doesn't have a translation.
How I'm using it at the moment:
import React from 'react'
import { Route } from 'react-router-dom'
import { IntlProvider } from 'react-intl'
import { Provider } from 'react-redux'
import { MuiThemeProvider, CssBaseline } from '#material-ui/core'
// import translations
import da_translations from './translations/da.json'
import de_translations from './translations/de.json'
import el_translations from './translations/el.json'
import en_translations from './translations/en.json'
import defaultTheme from './themes/default'
import {
QueryParamProvider,
ExtendedStringifyOptions,
transformSearchStringJsonSafe,
} from 'use-query-params'
import configureStore from './redux/configure-store'
import { Routes } from './routes'
const store = configureStore()
const App = (): JSX.Element => {
const state = { locale: navigator.language.slice(0, 2) }
const messages: { [index: string]: any } = {
da: da_translations,
de: de_translations,
el: el_translations,
en: en_translations,
}
const queryStringifyOptions: ExtendedStringifyOptions = {
transformSearchString: transformSearchStringJsonSafe,
}
return (
<Provider store={store}>
<IntlProvider
defaultLocale={'en'}
locale={state.locale}
messages={messages[state.locale]}
>
<QueryParamProvider
ReactRouterRoute={Route}
stringifyOptions={queryStringifyOptions}
>
<MuiThemeProvider theme={defaultTheme}>
<CssBaseline />
<Routes />
</MuiThemeProvider>
</QueryParamProvider>
</IntlProvider>
</Provider>
)
}
export default App
edit:
package.json
{
"name": "myproj",
"version": "0.8.47",
"description": "frontend",
"private": false,
"main": "dist/index.js",
"dependencies": {
"#babel/register": "^7.12.1",
"#date-io/date-fns": "^1.3.13",
"#google-cloud/translate": "^6.0.3",
"#material-ui/core": "^4.11.1",
"#material-ui/icons": "4.2.1",
"#material-ui/lab": "^4.0.0-alpha.56",
"#material-ui/pickers": "^3.2.10",
"#types/axios": "^0.14.0",
"#types/history": "^4.7.3",
"#types/jest": "^24.9.1",
"#types/lodash": "^4.14.158",
"#types/node": "^12.12.7",
"#types/react": "^16.9.11",
"#types/react-dom": "^16.9.4",
"#types/react-html-parser": "^2.0.1",
"#types/react-intl": "^3.0.0",
"#types/react-redux": "^7.1.9",
"#types/react-resizable": "^1.7.2",
"#types/react-router-dom": "^5.1.2",
"#types/reselect": "^2.2.0",
"#types/seamless-immutable": "^7.1.13",
"accept-language": "^3.0.18",
"ag-grid-community": "^23.1.1",
"ag-grid-react": "^23.1.1",
"axios": "^0.19.1",
"chai": "^4.2.0",
"chartist": "0.10.1",
"classnames": "^2.2.6",
"clsx": "^1.1.0",
"date-fns": "^2.9.0",
"flexsearch": "^0.6.32",
"fs-extra": "^9.0.1",
"history": "4.9.0",
"immutable": "^4.0.0-rc.12",
"js-yaml": "^3.14.0",
"lodash": "^4.17.19",
"log4js": "^6.3.0",
"loglevel": "^1.6.6",
"minimist": "^1.2.5",
"perfect-scrollbar": "1.4.0",
"prop-types": "15.7.2",
"qs": "^6.9.4",
"query-string": "^6.13.1",
"react": "^16.12.0",
"react-chartist": "0.13.3",
"react-dom": "^16.12.0",
"react-google-maps": "9.4.5",
"react-html-parser": "^2.0.2",
"react-intl": "^3.11.0",
"react-redux": "^7.2.1",
"react-resizable": "^1.10.1",
"react-router-dom": "^5.1.2",
"react-scripts": "4.0.0",
"react-swipeable-views": "0.13.3",
"redux": "^4.0.5",
"redux-observable": "^1.2.0",
"reselect": "^4.0.0",
"seamless-immutable": "^7.1.4",
"use-query-params": "^1.1.6"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test --env jest-environment-jsdom-sixteen --verbose",
"eject": "react-scripts eject",
"install:clean": "rm -rf node_modules/ && rm -rf package-lock.json && npm install && npm start",
"lint:check": "eslint . --ext=js,jsx; exit 0",
"lint:fix": "eslint . --ext=js,jsx --fix; exit 0",
"build-package-css": "cp src/assets/css/material-dashboard-react.css dist/material-dashboard-react.css",
"build-package": "npm run build-package-css && babel src --out-dir dist"
},
"keywords": [],
"author": "tb",
"license": "MIT",
"homepage": "./",
"optionalDependencies": {
"#types/googlemaps": "3.37.3",
"#types/markerclustererplus": "2.1.33",
"ajv": "6.10.2"
},
"devDependencies": {
"#testing-library/dom": "^7.24.2",
"#testing-library/jest-dom": "^5.11.1",
"#testing-library/react": "^10.4.7",
"#testing-library/user-event": "^12.1.4",
"#types/chai": "^4.2.13",
"#types/classnames": "^2.2.10",
"#types/enzyme": "^3.10.5",
"#types/enzyme-adapter-react-16": "^1.0.6",
"#types/gulp": "^4.0.7",
"#types/jsdom": "^16.2.2",
"#typescript-eslint/eslint-plugin": "^4.7.0",
"#typescript-eslint/parser": "^4.7.0",
"axios-mock-adapter": "^1.18.2",
"cross-env": "^5.1.4",
"enzyme": "^3.11.0",
"enzyme-adapter-react-16": "^1.15.2",
"eslint-config-prettier": "6.0.0",
"eslint-plugin-prettier": "3.1.0",
"eslint-plugin-react": "^7.21.5",
"eslint-plugin-react-hooks": "^4.2.0",
"gulp": "^4.0.2",
"gulp-append-prepend": "1.0.8",
"gulp-filter": "^6.0.0",
"gulp-prettier": "^3.0.0",
"husky": "^4.3.0",
"jest-environment-jsdom-sixteen": "^1.0.3",
"jsdom": "^16.2.2",
"prettier": "^2.1.2",
"pretty-quick": "^3.1.0",
"react-intl-translations-manager": "^5.0.3",
"ts-node": "^9.0.0",
"typescript": "^3.9.7"
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": []
},
"husky": {
"hooks": {
"pre-commit": "pretty-quick --staged"
}
},
"jest": {
"transformIgnorePatterns": [
"node_modules/(?!(#ui5|lit-html)).*\\.js$"
]
}
}
I am modifying a forum software at here
After installing "npm install -S react-draft-wysiwyg" on that forum project, I tried to apply global css by putting "import 'react-draft-wysiwyg/dist/react-draft-wysiwyg.css';" at the top of some React component js file in that forum software.
But it looks like something is blocking global CSS. CSS in that import didn't affect React js file. But I do not know what is blocking global css. My only guess is could be somewhat related to webpack but not sure.
I tried making a new react project by "npx create-react-app" and applied that global css, and it worked there. So I concluded that something is blocking global css in that forum project so that global CSS implementation doesn't work in that forum software only.
Here is package.json that forum software uses:
{
"name": "reforum",
"version": "1.0.0",
"description": "A forum application built with ReactJS, Redux, Express and MongoDB",
"license": "MIT",
"keywords": [
"forum",
"react",
"redux",
"express",
"mongodb"
],
"main": "server.js",
"engines": {
"node": "7.1.0"
},
"scripts": {
"test": "jest",
"start": "better-npm-run start",
"start:dev": "better-npm-run start:dev",
"build": "webpack --config config/webpack.prod.config.js"
},
"betterScripts": {
"start": {
"command": "node server.js",
"env": {
"NODE_ENV": "production",
"PORT": 3030
}
},
"start:dev": {
"command": "node server.js",
"env": {
"NODE_ENV": "development",
"PORT": 8080
}
}
},
"dependencies": {
"better-npm-run": "^0.0.13",
"body-parser": "^1.15.2",
"compression": "^1.6.2",
"connect-flash": "^0.1.1",
"connect-mongo": "^1.3.2",
"cookie-parser": "^1.4.3",
"express": "^4.14.0",
"express-session": "^1.14.2",
"help": "^3.0.2",
"lodash": "^4.17.4",
"mongoose": "^4.7.4",
"morgan": "^1.7.0",
"passport": "^0.3.2",
"passport-github": "^1.1.0",
"passport-local": "^1.0.0"
},
"devDependencies": {
"async": "^2.1.5",
"autoprefixer": "^6.6.1",
"axios": "^0.15.3",
"babel": "^6.5.2",
"babel-core": "^6.20.0",
"babel-eslint": "^7.1.1",
"babel-jest": "^20.0.3",
"babel-loader": "^6.2.9",
"babel-preset-es2015": "^6.18.0",
"babel-preset-react": "^6.16.0",
"babel-preset-stage-2": "^6.18.0",
"classnames": "^2.2.5",
"css-loader": "^0.26.1",
"draft-js": "^0.10.0",
"eslint": "^3.12.1",
"eslint-plugin-react": "^6.8.0",
"extract-text-webpack-plugin": "^1.0.1",
"file-loader": "^0.9.0",
"jest": "^20.0.4",
"moment": "^2.17.1",
"nock": "^9.0.13",
"postcss-loader": "^1.2.2",
"postcss-nesting": "^2.3.1",
"react": "^15.4.1",
"react-dom": "^15.4.1",
"react-helmet": "^5.0.3",
"react-hot-loader": "^1.3.1",
"react-onclickoutside": "^5.10.0",
"react-redux": "^5.0.2",
"react-router": "^3.0.0",
"redux": "^3.6.0",
"redux-mock-store": "^1.2.3",
"redux-thunk": "^2.2.0",
"style-loader": "^0.13.1",
"url-loader": "^0.5.7",
"webpack": "^1.14.0",
"webpack-dev-middleware": "^1.8.4",
"webpack-hot-middleware": "^2.13.2"
}
}
Can you please tell me what is blocking global CSS implementation?
Thank you very much.
You are using css-loader in webpack. So normal css will be compiled to another name such as
localIdentName: "[local]___[hash:base64:5]"
You can write your css with global such as
:global(.myclass) {
background-color: red;
}
or you can disable module in your webpack config
{
loader: "css-loader",
options: {
modules: false,
}
},
I am trying to run JEST for the react code,it always shows PASS and not running any script written inside test folder.Inside coverage folder also i am not getting any components folder being created.kindly let me know how to fix it
following are my configurations
package.json
{
"devDependencies": {
"axios": "^0.11.1",
"babel": "^6.5.2",
"babel-core": "^6.7.4",
"babel-eslint": "^4.1.6",
"babel-jest": "^9.0.3",
"babel-loader": "^6.2.4",
"babel-plugin-transform-runtime": "^6.6.0",
"babel-polyfill": "^6.3.14",
"babel-preset-es2015": "^6.6.0",
"babel-preset-react": "^6.5.0",
"bower-webpack-plugin": "^0.1.9",
"css-loader": "^0.23.1",
"es6-promise": "^3.2.1",
"es6bindall": "0.0.5",
"eslint": "^1.10.3",
"eslint-loader": "^1.0.0",
"eslint-plugin-react": "^5.0.0",
"express": "^4.13.4",
"extract-text-webpack-plugin": "^1.0.1",
"file-loader": "^0.8.4",
"grunt": "^1.0.1",
"grunt-cli": "^1.2.0",
"grunt-jest": "^0.2.0",
"grunt-webpack": "^1.0.11",
"imports-loader": "^0.6.5",
"jasmine-ajax": "^3.2.0",
"jest-cli": "^0.9.2",
"node-sass": "^3.4.2",
"react": "^15.0.0",
"react-dom": "^15.0.0",
"react-fileupload": "^2.2.0",
"react-hot-loader": "^1.2.9",
"react-router": "^2.6.1",
"sass-loader": "^3.2.0",
"sinon": "^1.17.4",
"style-loader": "^0.13.1",
"webpack": "^1.12.14",
"webpack-dev-server": "^1.14.1"
},
"scripts": {
"prestart": "webpack",
"build": "webpack",
"test": "jest",
"lint": "node_modules/.bin/eslint -f html app-client.js components > report.html || exit 0",
"start": "node app-server.js"
},
"jest": {
"scriptPreprocessor": "<rootDir>/jest-script-preprocessor",
"collectCoverage": true,
"preprocessorIgnorePatterns": [
"../frontend/node_modules/"
],
"testFileExtensions": [
"js",
"es6"
],
"moduleFileExtensions": [
"js",
"json",
"es6"
],
"unmockedModulePathPatterns": [
"react",
"fbjs",
"react-dom",
"react-addons-test-utils",
"es6bindall",
"axios",
"promise",
"react-router",
"sinon"
],
"verbose": true
}
}
The folder for your tests should be __tests__ not tests. If you want to change that you need to use testRegex option.
If you want run it with coverage you can do:
jest --coverage
or in your script case:
npm test -- --coverage
Be aware that I am talking about latest version of Jest (14.x). You can find an example I wrote about setting up Jest and running tests with or without coverage.