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

validate pass but cannot run #153

Open
willin opened this issue Feb 6, 2017 · 0 comments
Open

validate pass but cannot run #153

willin opened this issue Feb 6, 2017 · 0 comments

Comments

@willin
Copy link

willin commented Feb 6, 2017

error info:

node src/app/server.js


/Users/willin/Desktop/test/electronvue/node_modules/webpack/lib/webpack.js:19
                throw new WebpackOptionsValidationError(webpackOptionsValidationErrors);
                ^

Error
    at webpack (/Users/willin/Desktop/test/electronvue/node_modules/webpack/lib/webpack.js:19:9)
    at Object.<anonymous> (/Users/willin/Desktop/test/electronvue/src/app/server.js:7:18)
    at Module._compile (module.js:571:32)
    at Object.Module._extensions..js (module.js:580:10)
    at Module.load (module.js:488:32)
    at tryModuleLoad (module.js:447:12)
    at Function.Module._load (module.js:439:3)
    at Module.runMain (module.js:605:10)
    at run (bootstrap_node.js:420:7)
    at startup (bootstrap_node.js:139:9)
    at bootstrap_node.js:535:3

webpack-config:

base.js

const path = require('path');

module.exports = {
  module: {
    loaders: [{
      test: /\.vue?$/,
      loader: 'vue-loader',
      exclude: /node_modules/
    }, {
      test: /\.js$/,
      loader: 'babel-loader',
      query: {
        presets: ['latest'],
        plugins: [
          'transform-runtime'
        ]
      }
    }, {
      test: /\.(jpe?g|png|gif|svg)$/i,
      loaders: [
        'file?hash=sha512&digest=hex&name=[hash].[ext]',
        'image-webpack?bypassOnDebug&optimizationLevel=7&interlaced=false'
      ]
    }]
  },
  output: {
    path: path.join(__dirname, '../../build'),
    filename: 'app.js',
    publicPath: '/'
  },
  resolve: {
    root: path.join(__dirname, '../../'),
    extensions: ['', '.js', '.vue'],
    modulesDirectories: ['node_modules', 'src'],
    packageMains: ['webpack', 'browser', 'web', 'browserify', ['jam', 'main'], 'main'],
    alias: {}
  },
  plugins: [

  ],
  externals: [
  ]
};

development.js:

const webpack = require('webpack');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const baseConfig = require('./base');
const path = require('path');

const config = Object.create(baseConfig);

config.debug = true;

config.devtool = 'cheap-module-eval-source-map';

config.entry = [
  'webpack-hot-middleware/client?noInfo=true&reload=true',
  './src/app/app.js'
];

config.output.publicPath = 'http://localhost:3000/build/';

config.module.loaders.push({
  test: /^((?!\.module).)*\.css$/,
  loaders: [
    'style-loader',
    'css-loader'
  ]
}, {
  test: /\.module\.css$/,
  loaders: [
    'style-loader',
    'css-loader?modules&importLoaders=1&localIdentName=[name]__[local]___[hash:base64:5]!'
  ]
});

// config.resolve.alias.config = path.join(__dirname, '../config/development.js');

config.plugins.push(
  new webpack.HotModuleReplacementPlugin(),
  new webpack.NoErrorsPlugin(),
  new webpack.DefinePlugin({
    __DEV__: true,
    'process.env': {
      NODE_ENV: JSON.stringify('development')
    }
  }),
  new HtmlWebpackPlugin({
    filename: 'app.html',
    template: 'src/app/app.html'
  })
);

config.target = 'electron';

module.exports = config;

validate result:

[webpack-validator] Config is valid.
{ debug: true,
  devtool: 'cheap-module-eval-source-map',
  entry:
   [ 'webpack-hot-middleware/client?noInfo=true&reload=true',
     './src/app/app.js' ],
  target: 'electron' }

i found that:

const config = Object.create(baseConfig);
// console.log:   {} 

// ok
const config = new Object(baseConfig);

but still cannot run.

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

1 participant