Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot read property 'getSourceHash' of undefined #23

Open
ssilve1989 opened this issue May 29, 2018 · 6 comments
Open

Cannot read property 'getSourceHash' of undefined #23

ssilve1989 opened this issue May 29, 2018 · 6 comments
Labels
bug Something isn't working

Comments

@ssilve1989
Copy link

Hi

When trying to make a production build using the following command
WEBPACK_CONFIG_FILE=\"webpack.prod.js\" meteor build --architecture=os.linux.x86_64 --allow-superuser --directory .build
I get the following error:

Errors prevented bundling:
While processing files with ardatan:webpack (for target web.browser):
packages/webpack_plugin.js:74:43: Cannot read property 'getSourceHash' of undefined (at Object.processFilesForTarget)

While processing files with ardatan:webpack (for target os.linux.x86_64):
packages/webpack_plugin.js:74:43: Cannot read property 'getSourceHash' of undefined (at Object.processFilesForTarget)

I assume its printing twice, one for each bundle, client/server

My webpack configs are pretty simple:

// webpack.common.js
const meteorExternals = require('webpack-meteor-externals');
const path = require('path');
const TsConfigPathsPlugin = require('tsconfig-paths-webpack-plugin');

module.exports = {
  devtool: 'cheap-module-source-map',
  resolve: {
    extensions: ['.json', '.js', '.jsx', '.ts', '.tsx'],
    alias: {
      tests: path.resolve(__dirname, 'tests'),
      '/imports': path.resolve(__dirname, 'imports'),
      imports: path.resolve(__dirname, 'imports'),
    },
    plugins: [
      new TsConfigPathsPlugin({
        configFile: path.resolve(__dirname, 'tsconfig.json'),
      }),
    ],
  },
  module: {
    rules: [
      {
        test: /\.jsx?$/,
        use: 'babel-loader?cacheDirectory',
        exclude: /node_modules/,
      },
      {
        test: /\.tsx?$/,
        use: 'ts-loader',
        exclude: /node_modules/,
      },
    ],
  },
  externals: [meteorExternals()],
};
// webpack.prod.js
const merge = require('webpack-merge');
const path = require('path');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const webpack = require('webpack');

const webpackCommon = require('./webpack.common');

const clientConfig = merge(webpackCommon, {
  devtool: 'sourcemap',
  entry: [path.resolve(__dirname, 'client', 'main')],
  mode: 'production',
  module: {
    rules: [
      {
        test: /\.scss/,
        use: ['style-loader', 'css-loader', 'sass-loader'],
      },
      {
        test: /\.css/,
        use: ['style-loader', 'css-loader'],
      },
    ],
  },
  plugins: [
    new HtmlWebpackPlugin({
      template: './client/main.html',
    }),
    new webpack.DefinePlugin({ 'process.env.NODE_ENV': JSON.stringify('production') }),
  ],
});

const serverConfig = merge(webpackCommon, {
  devtool: 'sourcemap',
  mode: 'production',
  entry: path.resolve(__dirname, 'server'),
  target: 'node',
});

module.exports = [clientConfig, serverConfig];
@ssilve1989
Copy link
Author

This looks like a problem with WEBPACK_CONFIG_FILE is that not the correct way to specify a different file?

@rGiladi
Copy link
Contributor

rGiladi commented May 29, 2018

you can clone ardatan:webpack into a packages folder in your app and then debug this line

if you still can't find the problem - upload a simple repo to github that produces that error and i'll try it

@ardatan
Copy link
Owner

ardatan commented Jun 3, 2018

It will be fixed in the next release, so you can use default webpack configuration name and environment variables for detection of production mode as a current workaround.

@ardatan ardatan added the bug Something isn't working label Sep 12, 2018
@onhate
Copy link

onhate commented Jun 14, 2019

hi @ardatan, is there something I can do to help releasing a new version with this fix?

@powderham
Copy link

I came across this bug yesterday, the problem is with how you're specifying the webpack config, it shouldn't have quotes:

WEBPACK_CONFIG_FILE=webpack.prod.js

@atomoc
Copy link

atomoc commented Jan 3, 2020

Make sure that there is a line in the .meteorignore file:
!webpack.prod.js

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

6 participants