airyland / vux-loader

hack into vue-loader
64 stars 37 forks source link

[Bug Report] vux-loader结合vue-hackernews-2.0的时候报错 #56

Closed iamgaohui closed 6 years ago

iamgaohui commented 6 years ago

vux-loader version

1.0.61

OS/Browsers version

Mac os10.13.1/Chrome 66.0.3359.117

Vue version

2.5.16

Code

const path = require('path')
const webpack = require('webpack')
var utils = require('./utils')
var config = require('../config')
var merge = require('webpack-merge')
const ExtractTextPlugin = require('extract-text-webpack-plugin')
const FriendlyErrorsPlugin = require('friendly-errors-webpack-plugin')
const { VueLoaderPlugin } = require('vue-loader')
const isProd = process.env.NODE_ENV === 'production'
const vuxLoader = require('vux-loader')
var vueLoaderConfig = require('./vue-loader.conf')

function resolve (dir) {
  return path.join(__dirname, '..', dir)
}

let baseConfig = {
  devtool: isProd
    ? false
    : '#cheap-module-source-map',
  output: {
    path: path.resolve(__dirname, '../dist'),
    publicPath: '/dist/',
    filename: '[name].[chunkhash].js'
  },
  resolve: {
    extensions: ['.js', '.vue', '.json'],
    alias: {
      'public': path.resolve(__dirname, '../public'),
      '@': resolve('src'),
    },
  },
  module: {
    noParse: /es6-promise\.js$/, // avoid webpack shimming process
    rules: [
      {
        test: /\.vue$/,
        loader: 'vue-loader',
        options: vueLoaderConfig
      },
      {
        test: /\.js$/,
        loader: 'babel-loader',
        include: [resolve('src'), resolve('test')]
      },
      {
        test: /\.(png|jpg|gif|svg)$/,
        loader: 'url-loader',
        options: {
          limit: 10000,
          name: '[name].[ext]?[hash]'
        }
      },
    ].concat(utils.styleLoaders({ sourceMap: config.dev.cssSourceMap }))
  },
  performance: {
    maxEntrypointSize: 300000,
    hints: isProd ? 'warning' : false
  },
  plugins: isProd
    ? [
        new VueLoaderPlugin(),
        new webpack.optimize.UglifyJsPlugin({
          compress: { warnings: false }
        }),
        new webpack.optimize.ModuleConcatenationPlugin(),
        new ExtractTextPlugin({
          filename: 'common.[chunkhash].css'
        })
      ]
    : [
        new VueLoaderPlugin(),
        new FriendlyErrorsPlugin()
      ]
}
module.exports = vuxLoader.merge(baseConfig, {
   plugins: ['vux-ui', 'progress-bar', 'duplicate-style']
})

Steps to reproduce

这是vux结合vue的服务端渲染框架vue-hackernews-2.0的时候, npm run dev或者npm run build都会报错;

What is Expected?

npm run dev能正常跑通

What is actually happening?

错误如下:

error in ./src/components/Hello.vue

Module parse failed: Unexpected token (6:15) You may need an appropriate loader to handle this file type. function injectStyles (context) {
var style0 = ../../node_modules/vux-loader/src/style-loader.js!require("./Hello.vue?vue&type=style&index=0&id=361a4bd2&lang=less&scoped=true")
if (style0.inject) style0.inject(context)

@ ./src/router/index.js 3:0-39 @ ./src/app.js @ ./src/entry-server.js

(node:2037) DeprecationWarning: loaderUtils.parseQuery() received a non-string value which can be problematic, see https://github.com/webpack/loader-utils/issues/56

iamgaohui commented 6 years ago

重复