Browse Source

ref(build): Minor webpack / jest config cleanup (#11616)

Evan Purkhiser 6 years ago
parent
commit
21277b2c7e
2 changed files with 12 additions and 10 deletions
  1. 4 1
      scripts/test.js
  2. 8 9
      webpack.config.js

+ 4 - 1
scripts/test.js

@@ -1,4 +1,5 @@
-'use strict';
+/* global process */
+/* eslint import/no-nodejs-modules:0 */
 
 // Do this as the first thing so that any code reading it knows the right env.
 // process.env.BABEL_ENV = 'test';
@@ -13,7 +14,9 @@ process.on('unhandledRejection', err => {
   throw err;
 });
 
+// eslint-disable-next-line jest/no-jest-import
 const jest = require('jest');
+
 const argv = process.argv.slice(2);
 
 // Watch unless on CI or in coverage mode

+ 8 - 9
webpack.config.js

@@ -20,9 +20,8 @@ const USE_HOT_MODULE_RELOAD = !IS_PRODUCTION && WEBPACK_DEV_PORT && SENTRY_DEVSE
 const WEBPACK_MODE = IS_PRODUCTION ? 'production' : 'development';
 
 // this is set by setup.py sdist
-const staticPrefix = 'src/sentry/static/sentry';
-const distPath =
-  env.SENTRY_STATIC_DIST_PATH || path.join(__dirname, staticPrefix, 'dist');
+const staticPrefix = path.join(__dirname, 'src/sentry/static/sentry');
+const distPath = env.SENTRY_STATIC_DIST_PATH || path.join(staticPrefix, 'dist');
 
 /**
  * Locale file extraction build step
@@ -182,12 +181,12 @@ const cacheGroups = {
 const appConfig = {
   mode: WEBPACK_MODE,
   entry: {app: 'app'},
-  context: path.join(__dirname, staticPrefix),
+  context: staticPrefix,
   module: {
     rules: [
       {
         test: /\.jsx?$/,
-        include: path.join(__dirname, staticPrefix),
+        include: [staticPrefix],
         exclude: /(vendor|node_modules|dist)/,
         use: {
           loader: 'babel-loader',
@@ -271,7 +270,7 @@ const appConfig = {
   ],
   resolve: {
     alias: {
-      app: path.join(__dirname, 'src', 'sentry', 'static', 'sentry', 'app'),
+      app: path.join(staticPrefix, 'app'),
       'app-test': path.join(__dirname, 'tests', 'js'),
       'sentry-locale': path.join(__dirname, 'src', 'sentry', 'locale'),
       'integration-docs-platforms':
@@ -312,20 +311,20 @@ const legacyCssConfig = {
     // e.g. Trello, Teamwork
     select2: 'less/select2.less',
   },
-  context: path.join(__dirname, staticPrefix),
+  context: staticPrefix,
   output: {
     path: distPath,
   },
   plugins: [new ExtractTextPlugin()],
   resolve: {
     extensions: ['.less', '.js'],
-    modules: [path.join(__dirname, staticPrefix), 'node_modules'],
+    modules: [staticPrefix, 'node_modules'],
   },
   module: {
     rules: [
       {
         test: /\.less$/,
-        include: path.join(__dirname, staticPrefix),
+        include: [staticPrefix],
         use: [ExtractTextPlugin.loader, 'css-loader', 'less-loader'],
       },
       {