首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >vue热重装不重装

vue热重装不重装
EN

Stack Overflow用户
提问于 2016-09-12 15:56:41
回答 1查看 14.7K关注 0票数 4

和webpack一起使用Vuejs。

我安装了vue热重装:

代码语言:javascript
复制
"vue-hot-reload-api": "^2.0.6"

然后启动webpack开发服务器,并能够查看页面唱歌http://localhsot:8080

代码语言:javascript
复制
webpack-dev-server --inline --hot

问:页面更改不是自动重新加载的,我必须运行webpack命令来查看更改。

wepack.config.js:

代码语言:javascript
复制
module.exports = {
  // This is the "main" file which should include all other modules
  entry: './app/main.js',
  // Where should the compiled file go?
  output: {
    // To the `dist` folder
    path: './dist',
    // With the filename `build.js` so it's dist/build.js
    filename: 'build.js'
  },
  module: {
    // Special compilation rules
    loaders: [
      {
        // Ask webpack to check: If this file ends with .js, then apply some transforms
        test: /\.js$/,
        // Transform it with babel
        loader: 'babel',
        // don't transform node_modules folder (which don't need to be compiled)
        exclude: /node_modules/
      },
      {
          test: /\.vue$/,
          loader: 'vue'
      }
    ]
  },
  babel: {
    presets: ['es2015'],
    plugins: ['transform-runtime']
  },
  vue: {
    loaders: {
      js: 'babel'
    }
  }
}

package.json:

代码语言:javascript
复制
{
  "name": "xx",
  "version": "0.0.1",
  "description": "xx",
  "main": "main.js",
  "scripts": {
    "start": "electron ."
  },
  "keywords": [
    "vue",
    "electron"
  ],
  "author": "xx",
  "license": "MIT",
  "devDependencies": {
    "babel-core": "^6.14.0",
    "babel-loader": "^6.2.5",
    "babel-plugin-transform-runtime": "^6.15.0",
    "babel-preset-es2015": "^6.14.0",
    "babel-preset-stage-0": "^6.5.0",
    "babel-runtime": "^6.11.6",
    "electron": "^1.3.5",
    "vue-hot-reload-api": "^2.0.6",
    "vue-html-loader": "^1.2.3",
    "vue-loader": "^8.5.2",
    "vue-style-loader": "^1.0.0",
    "webpack": "^1.13.2",
    "webpack-dev-server": "^1.15.1"
  },
  "dependencies": {
    "bootstrap": "^3.3.7",
    "pouchdb": "^6.0.4",
    "vue": "^1.0.26",
    "vue-resource": "^1.0.1",
    "vue-router": "^0.7.13"
  }
}
EN

回答 1

Stack Overflow用户

发布于 2016-09-28 12:01:46

直到我在webpack.config.js,中添加了publicPath: dist/,我的dev服务器才开始工作。

如果你面临着和我一样的问题,也许你可以试一试。

代码语言:javascript
复制
output: {
    path: './dist',
    filename: 'build.js',
    // ↓↓↓↓↓add this to make dev-server working
    publicPath: 'dist/', 
}
票数 5
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/39454345

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档