meteor-webpack
meteor-webpack copied to clipboard
Cannot read property 'getSourceHash' of undefined
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];
This looks like a problem with WEBPACK_CONFIG_FILE is that not the correct way to specify a different file?
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
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.
hi @ardatan, is there something I can do to help releasing a new version with this fix?
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
Make sure that there is a line in the .meteorignore file:
!webpack.prod.js