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

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

Open
iamgaohui opened this issue Apr 27, 2018 · 1 comment
Open

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

iamgaohui opened this issue Apr 27, 2018 · 1 comment

Comments

@iamgaohui
Copy link

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 webpack/loader-utils#56

@iamgaohui
Copy link
Author

vux-loader换成最新的1.2.8版本后

Module parse failed: Unexpected token (3:0)
You may need an appropriate loader to handle this file type.
| import { render, staticRenderFns } from "./UserView.vue?vue&type=template&id=4d74474a"
| import script from "./UserView.vue?vue&type=script&lang=js"
| ../../node_modules/vux-loader/src/script-loader.js!export * from "./UserView.vue?vue&type=script&lang=js"
|
|

@ ./src/router/index.js 18:9-40
@ ./src/app.js
@ ./src/entry-client.js
@ multi webpack-hot-middleware/client ./src/entry-client.js

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