Webpack-dev-server: Message about "setup" when using cli only

Created on 27 Sep 2017  Â·  5Comments  Â·  Source: webpack/webpack-dev-server

  • Operating System: macOS
  • Node Version: v8.5.0
  • NPM Version: 5.4.2
  • webpack Version: 3.6.0
  • webpack-dev-server Version: 2.9.0
  • [ ] This is a bug
  • [ ] This is a feature request
  • [x] This is a modification request

Code

$ node ./node_modules/.bin/webpack-dev-server --host XXX --port 80 --history-api-fallback --hot --config=./webpack.babel.js --env.api=alpha --env.flag=alpha

Expected Behavior

No message.

Actual Behavior

Using "setup" is deprecated and will be removed in the next major version. Please use the "before" and "after" hooks instead.
If "setup" was working fine for you until now, simply replace it with "before"

For Bugs; How can we reproduce the behavior?

For Features; What is the motivation and/or use-case for the feature?

chore

Most helpful comment

Fixed in 8de5d0a2bf9916439b268b7b7d9ba2d613f35234 and published

All 5 comments

This is by design. Change your config to use before instead of setup as instructed by the message and the message will not be shown.

I understand the point but… where I've got any setup thing in my config? O_o

// webpack.config.js

import path from 'path'
import webpack from 'webpack'
import HtmlWebpackPlugin from 'html-webpack-plugin'

import babelConfig from './babel.config.js'
import envVars from './env.json'

const SRC_DIR = path.resolve(__dirname, 'src')
const DIST_DIR = path.resolve(__dirname, 'dist')

export default (env) => {
  return {
    // the source
    entry: [
      'react-hot-loader/patch',
      `${SRC_DIR}/index.js`,
    ],

    // the destination
    output: {
      path: DIST_DIR,
      filename: 'index.js',
      publicPath: '/'
    },

    resolve: {
      alias: {
        '~': `${SRC_DIR}`, // thanks to that, we can use import xxx from '~/file'
      }
    },

    // active devtools
    // devtool: 'eval',
    devtool: 'cheap-module-inline-source-map',
    // devtool: 'cheap-module-source-map',

    // plugins
    plugins: [
      new HtmlWebpackPlugin({
        template: 'src/index.html',
        favicon: 'src/favicon.ico',
        segmentToken: JSON.stringify(envVars[env.flag].SEGMENT_TOKEN),
      }),

      new webpack.DefinePlugin({
        API_URL: JSON.stringify(envVars[env.api].API_URL),
        JOURNAL_URL: JSON.stringify(envVars[env.flag].JOURNAL_URL),
        FLAG: JSON.stringify(env.flag),
        'process.env': {
          'NODE_ENV': JSON.stringify('development')
        }
      }),
    ],

    // what will be used for each type of code
    module: {
      rules: [
        // javascript
        {
          test: /\.jsx?$/,
          exclude: /node_modules/,
          loader: 'babel-loader',
          options: babelConfig,
        },

        // files
        {
          test: /\.(png|woff|woff2|eot|ttf|svg)$/,
          use: {
            loader: 'url-loader',
            options: {
              limit: 100000
            }
          }
        },

        // styles
        {
          test: /\.css$/,
          exclude: /\.module\.css$/,
          use: [
            {
              loader: 'style-loader',
            },
            {
              loader: 'css-loader',
              options: {
                modules: false,
                importLoaders: 1,
                import: true,
                alias: {
                  '~': `${SRC_DIR}`
                }
              }
            },
            {
              loader: 'postcss-loader'
            }
          ]
        },

        {
          test: /\.module\.css$/,
          use: [
            {
              loader: 'style-loader',
            },
            {
              loader: 'css-loader',
              options: {
                modules: true,
                importLoaders: 1,
                localIdentName: '[path][name]--[local]-___[hash:base64:5]',
                import: true,
                alias: {
                  '~': `${SRC_DIR}`
                }
              }
            },
            {
              loader: 'postcss-loader'
            }
          ]
        },

        // images
        {
          test: /.*\.(gif|png|jpe?g|svg)$/i,
          use: [
            {
              loader: 'file-loader'
            }
          ]
        }
      ]
    }
  }
}

Yep. Looks like we missed the position of those messages. Patch will be published.

Fixed in 8de5d0a2bf9916439b268b7b7d9ba2d613f35234 and published

Was this page helpful?
0 / 5 - 0 ratings

Related issues

mischkl picture mischkl  Â·  3Comments

piotrszaredko picture piotrszaredko  Â·  3Comments

MJ111 picture MJ111  Â·  3Comments

Ky6uk picture Ky6uk  Â·  3Comments

uMaxmaxmaximus picture uMaxmaxmaximus  Â·  3Comments