0

Here is a piece of my webpack config file: `

// webpack.config.js  
  entry: path.resolve(__dirname, 'src/app.js'),
  output: {
    filename: 'bundle.js',
    path: path.resolve(__dirname, 'dist/js/'),
    library: 'app',
    publicPath: '/js/',
    pathinfo: NODE_ENV === 'development',
  },
  //...
    module: {
    rules: [
      {
        test: /\.js$/,
        exclude: /(node_modules|bower_components)/,
        use: [
          {
            loader: 'babel',
          },
          {
            loader: 'eslint',
          },
        ],
      },    
      //...    
    ],
  },
  
  
 // .babelrc
 {
  "presets": [
    [
      "env",
      {
        "targets": {
          "browsers": [
            "last 1 Chrome versions",
            "last 1 Firefox versions",
            "last 1 Edge versions",
            "last 1 iOS versions"
          ]
        },
        "modules": false
      }
    ]
  ],
  "plugins": [
    ["istanbul", {
      "exclude": [
        "./test/unit/**/*.js"
      ]
    }]
  ]
}

The Problem: I get the full local path to my js file like this: path: '/Users/username/MyProjects/projectname/src/view/dialog/Messages.js. Which don't like to have in my production bundle.

I get this only using babel-loader for js files.

I use "webpack": "3.8.1".

Please help!

Olga
  • 21
  • 5

2 Answers2

1

The problem resolved. The reason was Istanbul Babel plugin. The solution is to use 'test' variable and use Istanbul in test mode only:

// .babelrc

{
  "presets": [
    [
     // ...
  ],
  "env": {
    "test": {
      "plugins": [
        ["istanbul", {
          "exclude": [
            "./test/unit/**/*.js"
          ]
        }]
      ]
    }
  }
}
Olga
  • 21
  • 5
-1

this might help.

const path = require('path');
path.join(process.cwd()

ex: 
"rxjs/AsyncSubject": path.join(process.cwd(), "/node_modules/rxjs/_esm5/AsyncSubject.js")
kennanwho
  • 171
  • 1
  • 3
  • 14