【问题标题】:Webpack publicPath is being ignored?Webpack publicPath 被忽略了吗?
【发布时间】:2017-07-29 03:17:22
【问题描述】:

只是无法弄清楚这有什么问题。我只是想让它从根目录服务,以便我做https://localhost/。但它只适用于https://localhost/public/publicPath 似乎被完全忽略了。

webpack.config.js

var webpack           = require('webpack'),
    ReplacePlugin     = require('replace-webpack-plugin'),
    CopyWebpackPlugin = require('copy-webpack-plugin');

module.exports = {
  entry: ['./src/app.js'],

  output: {
    path: __dirname + '/public',
    filename: 'app.min.js',
    publicPath: '/public/'
  },

  module: {
    loaders: [
      { test: /\.vue$/, loader: 'vue' },
      { test: /\.js$/, loader: 'babel', exclude: /node_modules/ }
    ]
  },

  babel: {
    presets: ['es2015'],
    plugins: ['transform-runtime']
  },

  devServer: {
    disableHostCheck: true,
    historyApiFallback: true
  }
}

package.json

{
  "dependencies": {
    "@websanova/vue-auth": "2.13.2-beta",
    "axios": "0.16.2",
    "vue-axios": "2.0.2"
  },

    "devDependencies": {
      "babel-core": "6.16.0",
      "babel-loader": "6.2.5",
      "babel-runtime": "6.9.2",
      "babel-plugin-transform-runtime": "6.12.0",
      "babel-preset-es2015": "6.16.0",

      "vue-loader": "12.2.1",

      "vue-style-loader": "3.0.1",
      "vue-template-compiler": "2.3.4",
      "css-loader": "0.28.4",
      "style-loader": "0.18.2",
      "file-loader": "0.11.2",

      "webpack": "1.13.1",
      "webpack-dev-server": "1.16.4",
      "webpack-stream": "3.2.0",
      "copy-webpack-plugin": "3.0.1",
      "replace-webpack-plugin": "0.1.2"
    },

    "scripts": {
      "demo": "webpack-dev-server --https --host=0.0.0.0 --port=8002"
    }
}

【问题讨论】:

  • index.html 文件在哪里?

标签: webpack webpack-dev-server webpack-2


【解决方案1】:

devServer 有问题。我认为您的index.html/public 文件夹中。

devServer: {
    disableHostCheck: true,
    historyApiFallback: true
    contentBase: path.join(__dirname, './public'),
}

【讨论】:

    【解决方案2】:

    问题是缺少运行行中的路径,应该使用-content-base=public/ 运行

    【讨论】:

      猜你喜欢
      • 2020-07-07
      • 2020-04-18
      • 1970-01-01
      • 1970-01-01
      • 2011-12-18
      • 2019-03-07
      • 2020-06-18
      • 2012-02-17
      • 1970-01-01
      相关资源
      最近更新 更多