Skip to content

Message about "setup" when using cli only #1118

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

Closed
1 of 3 tasks
kud opened this issue Sep 27, 2017 · 5 comments
Closed
1 of 3 tasks

Message about "setup" when using cli only #1118

kud opened this issue Sep 27, 2017 · 5 comments

Comments

@kud
Copy link

kud commented Sep 27, 2017

  • 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
  • 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?

@shellscape
Copy link
Contributor

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.

@kud
Copy link
Author

kud commented Sep 27, 2017

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

@kud
Copy link
Author

kud commented Sep 27, 2017

// 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'
            }
          ]
        }
      ]
    }
  }
}

@shellscape
Copy link
Contributor

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

@shellscape
Copy link
Contributor

Fixed in 8de5d0a and published

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

No branches or pull requests

2 participants