Article From:https://segmentfault.com/q/1010000013342370
Question:

vue Reference style problem

app.vue The code is as follows

<template>
  <div id="app">
    <el-button type="primary">The main button < /el-button>< el-button type= "danger" > main button < /el-button>< el-button tYpe= "info" icon= "close" > main button < /el-button>< el-button type= "success" icon= "Edit" > mainButton < /el-button>< el-button type= "warning" icon= "search" > main button < /el-button></div>< /template>< script>Export default {Data () {Return {Msg:'HellO Vue!}}}< /script>< style>< /style>

webpack The configuration is as follows

var path = require('path')
var webpack = require('webpack')

module.exports = {
  entry: './src/main.js',
  output: {
    path: path.resolve(__dirname, './dist'),
    publicPath: '/dist/',
    filename: 'build.js'
  },
  resolveLoader: {
    root: path.join(__dirname, 'node_modules'),
  },
  module: {
    loaders: [
      {
        test: /\.vue$/,
        loader: 'vue'
      },
      {
        test: /\.js$/,
        loader: 'babel',
        exclude: /node_modules/
      },
      {
        test: /\.css$/,
        loader: 'style!css'
      },
      {
        test: /\.(eot|svg|ttf|woff|woff2)$/,
        loader: 'file'
      },
      {
        test: /\.json$/,
        loader: 'json'
      },
      {
        test: /\.html$/,
        loader: 'vue-html'
      },
      {
        test: /\.(png|jpg|gif|svg)$/,
        loader: 'url',
        query: {
          limit: 10000,
          name: '[name].[ext]?[hash]'
        }
      }
    ]
  },
  devServer: {
    historyApiFallback: true,
    noInfo: true
  },
  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({
      compress: {
        warnings: false
      }
    }),
    new webpack.optimize.OccurenceOrderPlugin()
  ])
}

The problem seems to be in package.json, and it seems not? I spent the whole afternoon without finding any problems.


{
  "name": "map",
  "description": "A Vue.js project",
  "author": "",
  "scripts": {
    "dev": "webpack-dev-server --inline --hot",
    "build": "cross-env NODE_ENV=production webpack --progress --hide-modules"
  },
  "dependencies": {
    "babel-runtime": "^6.0.0",
    "element-ui": "^2.2.0",
    "style-loader": "^0.20.2",
    "vue": "^1.0.0"
  },
  "devDependencies": {
    "babel-core": "^6.0.0",
    "babel-loader": "^6.0.0",
    "babel-plugin-transform-runtime": "^6.0.0",
    "babel-preset-es2015": "^6.0.0",
    "babel-preset-stage-2": "^6.0.0",
    "cross-env": "^1.0.6",
    "css-loader": "^0.23.0",
    "file-loader": "^0.8.4",
    "json-loader": "^0.5.4",
    "url-loader": "^0.5.7",
    "vue-hot-reload-api": "^1.2.0",
    "vue-html-loader": "^1.0.0",
    "vue-loader": "^8.2.1",
    "vue-style-loader": "^1.0.0",
    "webpack": "^1.12.2",
    "webpack-dev-server": "^1.12.0"
  }
}

main.js The code is as follows:


import Vue from 'vue'
import ElementUI from 'element-ui'
import 'element-ui/lib/theme-chalk/index.css'
import App from './App.vue'

Vue.use(ElementUI)

new Vue({
  el: 'body',
  components: { App }
})

Problem: does the style reference be rough? (not reported)

Answer 0:

vue 1.X webpack 1.X

If you were studying recently. It is suggested that we should not be too entangled in this environment, and directly use vue-cli to build the development environment.

And you do this

  1. First, see if CSS has been loaded.
  2. I think there should be a problem with the webpack configuration CSS.

Similar Posts:

Link of this Article: Vue reference style problem

Leave a Reply

Your email address will not be published. Required fields are marked *