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

Webpack CLI seems to create invalid webpack.config.js: #134

Closed
svenvandescheur opened this issue May 11, 2017 · 2 comments
Closed

Webpack CLI seems to create invalid webpack.config.js: #134

svenvandescheur opened this issue May 11, 2017 · 2 comments

Comments

@svenvandescheur
Copy link

There seems to be an issue when running webpack on the configuration created by webpack-cli. Apparently, webpack-cli does not create an absolute path for dist where webpack expects it.

What is the current behavior?

$ webpack-cli

Insecure about some of the questions?

https://github.com/webpack/webpack-cli/blob/master/INIT.md

? Will you be creating multiple bundles? No
? Which module will be the first to enter the application? index.js
? Which folder will your generated bundles be in? [default: dist]:
? Are you going to use this in production? No
? Will you be using ES2015? Yes
? Will you use one of the below CSS solutions? No
? If you want to bundle your CSS files, what will you name the bundle? (press enter to skip)
? Name your 'webpack.[name].js?' [default: 'config']:
test@1.0.0 /Users/svenvandescheur/Desktop/test
├── babel-core@6.24.1
├── babel-loader@7.0.0
└── babel-preset-env@1.4.0

npm WARN test@1.0.0 No description
npm WARN test@1.0.0 No repository field.

Congratulations! Your new webpack configuration file has been created!

$ webpack

Invalid configuration object. Webpack has been initialised using a configuration object that does not match the API schema.
 - configuration.output.path: The provided value "./dist" is not an absolute path!

$ webpack -v

2.5.1

$ webpack-cli -v

1.3.1

$ node -v

v6.2.2

  • os X 10.11.6

$ cat webpack.config.js

const webpack = require('webpack');

/*
 * We've enabled UglifyJSPlugin for you! This minifies your app
 * in order to load faster and run less javascript.
 *
 * https://github.com/webpack-contrib/uglifyjs-webpack-plugin
 *
 */

const UglifyJSPlugin = require('uglifyjs-webpack-plugin');

module.exports = {
        entry: 'index.js',
        output: {
                filename: '[name].bundle.js',
                path: './dist'
        },

        module: {
                rules: [
                        {
                                test: /\.js$/,
                                exclude: /node_modules/,
                                loader: 'babel-loader',
                                options: {
                                        presets: ['es2015']
                                }
                        }
                ]
        },

        plugins: [new UglifyJSPlugin()]
};
@ghost
Copy link

ghost commented May 11, 2017

https://webpack.js.org/configuration/#options

Relative paths should be wrapped into path.resolve(__dirname, "./relative/path")

@evenstensberg
Copy link
Member

This is fixed in #125 .

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

No branches or pull requests

2 participants