Skip to content

Commands not found error after on hooks(onBuildStart and onBuildEnd) #69

Description

@bcano-office

This is how my Webpack config files looks like.

`const path = require('path');
const webpack = require('webpack');
const nodeExternals = require('webpack-node-externals');
const UglifyJSPlugin = require('uglifyjs-webpack-plugin');
const NodemonPlugin = require('nodemon-webpack-plugin');
const WebpackShellPlugin = require('webpack-shell-plugin');

const ENV = process.env.NODE_ENV.trim();

const isDev = ENV !== 'production';
const isProd = ENV === 'production';

function setDevTool() {
if (isDev) {
return 'inline-source-map';
} else if (isProd) {
return 'source-map';
} else {
return 'eval-source-map';
}
}

const browserConfig = {
mode: ENV,
entry: './src/client/index.js',
output: {
path: path.resolve(__dirname, 'public'),
filename: 'bundle.js',
publicPath: '/'
},
devtool: setDevTool(),
module: {
rules: [
{
test: /.(js)$/,
use: 'babel-loader'
}
]
},
plugins: [
new webpack.DefinePlugin({
isBrowser: "true"
})
]
}

const serverConfig = {
mode: ENV,
entry: './src/server/index.js',
target: 'node',
externals: [nodeExternals()],
output: {
path: __dirname,
filename: 'server.js',
publicPath: '/'
},
devtool: setDevTool(),
module: {
rules: [
{
test: /.(js)$/,
use: 'babel-loader'
}
]
},
plugins: [
new webpack.DefinePlugin({
isBrowser: "false"
})
]
}

if (isDev) {
serverConfig.plugins.push(
new NodemonPlugin()
);
}

if (isProd) {
browserConfig.plugins.push(
new UglifyJSPlugin({
sourceMap: true
})
);
serverConfig.plugins.push(
new UglifyJSPlugin({
sourceMap: true
}),
new WebpackShellPlugin({
onBuildStart: ['echo "Production Build Start."'],
onBuildEnd: ['node server.js']
})
);
}

module.exports = [browserConfig, serverConfig];
`

When I run 'NODE_ENV=production webpack -w', it returns error after webpack build.
Error: Command failed: node server.js

Please give me an idea why this error occurs if anybody knows why.
Thank you.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions