Webpack不起作用,不会抛出错误

时间:2017-06-22 07:32:47

标签: javascript webpack vue.js vue-component

我使用webpack来封装我的cart vuejs组件。该组件还有其他三个组件:

Cart.vue
CartLine.vue
CartResume.vue

执行npm run build后,使用我的vue组件构建一个唯一的js文件 - > cart.js

问题是没有任何反应,组件不起作用,chrome dev工具不会抛出错误。

有什么问题?我需要启动webpack吗?

这是我的HTML代码:

<div id="cart-section">
  <cart ref="cart_lines" :route_create="'{{ route('web.create',['$article_slug','$article_id']) }}?line_ref=$cart_line_id'" @onmodified="_onModified"></cart>

 <cart-resume ref="cart_resume" ></cart-resume>
</div>

这是我在html文档中的js:

Vue.config.debug = true; Vue.config.devtools = true;
        new Vue({

            el: '#cart-section',

            methods : {

                _onModified : function()
                {                
                    this.$refs.cart_resume.load();
                }
            },

        });

这是我的webpack配置:

var path              = require('path')
var webpack           = require('webpack')
var ExtractTextPlugin = require("extract-text-webpack-plugin")

module.exports = {
  //entry: './src/cart/main.js',
  entry: {
      cart    : "./src/cart/Cart.vue",
      tickets : "./src/tickets/tickets.vue.js",
  },
  output: {
    //path: path.resolve(__dirname, './dist'),
    path: path.join(__dirname, "dist"),    
    publicPath: '/dist/',
    filename: '[name]/[name].min.js'
  },
  module: {
    rules: [
      {
        test: /\.vue$/,
        loader: 'vue-loader',
        options: {
          loaders: {
            css: ExtractTextPlugin.extract({
              use: 'css-loader',
              fallback: 'vue-style-loader' // <- this is a dep of vue-loader, so no need to explicitly install if using npm3
            })
          }
          // other vue-loader options go here
        }
      },
      {
        test: /\.js$/,
        loader: 'babel-loader',
        exclude: /node_modules/
      },
      {
        test: /\.(png|jpg|gif|svg)$/,
        loader: 'file-loader',
        options: {
          name: '[name].[ext]?[hash]'
        }
      }
    ]
  },
  plugins: [
    new ExtractTextPlugin("[name]/[name].min.css"),
  ],
  resolve: {
    alias: {
      'vue$': 'vue/dist/vue.esm.js'
    }
  },
  devServer: {
    historyApiFallback: true,
    noInfo: true
  },
  performance: {
    hints: false
  },
  devtool: '#eval-source-map'
}

if (process.env.NODE_ENV === 'production') 
{
  module.exports.devtool = '#source-map'
  // http://vue-loader.vuejs.org/en/workflow/production.html
  module.exports.plugins = (module.exports.plugins || []).concat([
    new webpack.DefinePlugin({
      'process.env': {
        NODE_ENV: '"production"'
      }
    }),
    /*new webpack.optimize.UglifyJsPlugin({
      sourceMap: true,
      compress: {
        warnings: false
      }
    }),*/
    new webpack.LoaderOptionsPlugin({
      minimize: false
    })
  ])
}
else
{
  // dev
}

0 个答案:

没有答案