From 8817b5f0272ea3111a5d9308ae27dd91b464fa38 Mon Sep 17 00:00:00 2001 From: Jeff Avallone Date: Tue, 13 Feb 2018 20:09:52 -0500 Subject: [PATCH] Setting up webpack resolve root --- package.json | 6 +++++- src/components/App.js | 2 +- src/components/RavenBoundary/index.js | 2 +- src/components/RavenError/index.js | 4 ++-- src/pages/404/Component.js | 6 +++--- src/pages/404/browser.js | 10 +++++----- src/pages/index/Component.js | 8 ++++---- src/pages/index/browser.js | 12 ++++++------ src/{style.css => site.css} | 0 webpack.common.js | 3 +++ webpack.prod.js | 3 +++ 11 files changed, 33 insertions(+), 23 deletions(-) rename src/{style.css => site.css} (100%) diff --git a/package.json b/package.json index b7dc4eb..9da13e4 100644 --- a/package.json +++ b/package.json @@ -32,8 +32,12 @@ "snapshotSerializers": [ "enzyme-to-json/serializer" ], + "modulePaths": [ + "src", + "node_modules" + ], "moduleNameMapper": { - "\\.svg$": "/src/__mocks__/svgMock.js", + "\\.svg$": "__mocks__/svgMock.js", "\\.css$": "identity-obj-proxy" }, "collectCoverageFrom": [ diff --git a/src/components/App.js b/src/components/App.js index 4c4b404..743c5c1 100644 --- a/src/components/App.js +++ b/src/components/App.js @@ -1,6 +1,6 @@ import React from 'react'; -import Message from './Message'; +import Message from 'components/Message'; const App = () => ( diff --git a/src/components/RavenBoundary/index.js b/src/components/RavenBoundary/index.js index 886559e..9961ba7 100644 --- a/src/components/RavenBoundary/index.js +++ b/src/components/RavenBoundary/index.js @@ -1,7 +1,7 @@ import React from 'react'; import PropTypes from 'prop-types'; -import RavenError from '../RavenError'; +import RavenError from 'components/RavenError'; class RavenBoundary extends React.Component { constructor() { diff --git a/src/components/RavenError/index.js b/src/components/RavenError/index.js index 7520e13..a12e0f6 100644 --- a/src/components/RavenError/index.js +++ b/src/components/RavenError/index.js @@ -1,9 +1,9 @@ import React from 'react'; import PropTypes from 'prop-types'; import { translate, Trans } from 'react-i18next'; -import { Raven } from '../../sentry'; +import { Raven } from 'sentry'; -import Message from '../Message'; +import Message from 'components/Message'; import AlertIcon from 'feather-icons/dist/icons/alert-octagon.svg'; class RavenError extends React.Component { diff --git a/src/pages/404/Component.js b/src/pages/404/Component.js index 4c07aa0..d68afc7 100644 --- a/src/pages/404/Component.js +++ b/src/pages/404/Component.js @@ -2,10 +2,10 @@ import React from 'react'; import PropTypes from 'prop-types'; import { translate, Trans } from 'react-i18next'; -import Message from '../../components/Message'; +import Message from 'components/Message'; import AlertIcon from 'feather-icons/dist/icons/alert-octagon.svg'; -import Header from '../../components/Header'; -import Footer from '../../components/Footer'; +import Header from 'components/Header'; +import Footer from 'components/Footer'; const Component = ({ t }) => ( diff --git a/src/pages/404/browser.js b/src/pages/404/browser.js index 0bdcb16..74fcbb4 100644 --- a/src/pages/404/browser.js +++ b/src/pages/404/browser.js @@ -2,12 +2,12 @@ import React from 'react'; import ReactDOM from 'react-dom'; import Component from './Component'; -import RavenBoundary from '../../components/RavenBoundary'; +import RavenBoundary from 'components/RavenBoundary'; -import '../../style.css'; -import '../../i18n'; -import { setupGA } from '../../analytics'; -import { Raven, setupRaven } from '../../sentry'; +import 'site.css'; +import 'i18n'; +import { setupGA } from 'analytics'; +import { Raven, setupRaven } from 'sentry'; setupRaven(); diff --git a/src/pages/index/Component.js b/src/pages/index/Component.js index 6eb6828..8d04f97 100644 --- a/src/pages/index/Component.js +++ b/src/pages/index/Component.js @@ -1,10 +1,10 @@ import React from 'react'; -import Message from '../../components/Message'; +import Message from 'components/Message'; import AlertIcon from 'feather-icons/dist/icons/alert-octagon.svg'; -import Header from '../../components/Header'; -import Footer from '../../components/Footer'; -import App from '../../components/App'; +import Header from 'components/Header'; +import Footer from 'components/Footer'; +import App from 'components/App'; const Component = () => ( diff --git a/src/pages/index/browser.js b/src/pages/index/browser.js index 9fab7fc..e2deee8 100644 --- a/src/pages/index/browser.js +++ b/src/pages/index/browser.js @@ -2,13 +2,13 @@ import React from 'react'; import ReactDOM from 'react-dom'; import Component from './Component'; -import RavenBoundary from '../../components/RavenBoundary'; +import RavenBoundary from 'components/RavenBoundary'; -import '../../style.css'; -import '../../i18n'; -import { setupServiceWorker } from '../../service-worker'; -import { setupGA } from '../../analytics'; -import { Raven, setupRaven } from '../../sentry'; +import 'site.css'; +import 'i18n'; +import { setupServiceWorker } from 'service-worker'; +import { setupGA } from 'analytics'; +import { Raven, setupRaven } from 'sentry'; setupRaven(); diff --git a/src/style.css b/src/site.css similarity index 100% rename from src/style.css rename to src/site.css diff --git a/webpack.common.js b/webpack.common.js index 66b5611..2f78277 100644 --- a/webpack.common.js +++ b/webpack.common.js @@ -44,6 +44,9 @@ module.exports = { chunkFilename: 'js/[name].[chunkhash:8].js', path: path.resolve(__dirname, 'build') }, + resolve: { + modules: ['src', 'node_modules'] + }, plugins: [ new webpack.EnvironmentPlugin({ NODE_ENV: 'development', diff --git a/webpack.prod.js b/webpack.prod.js index 1e550ec..d0e4fe2 100644 --- a/webpack.prod.js +++ b/webpack.prod.js @@ -34,6 +34,9 @@ module.exports = [ chunkFilename: '[name].chunk.js', path: path.resolve(__dirname, 'prerender') }, + resolve: { + modules: ['src', 'node_modules'] + }, plugins: [ // Only want the EnvironmentPlugin common.plugins.find(plugin => plugin instanceof webpack.EnvironmentPlugin)