I figured it out. I indeed had to edit the publicPath
entry in my webpack.config.js
, like so:
var path = require('path')
var webpack = require('webpack')
const ExtractTextPlugin = require("extract-text-webpack-plugin")
module.exports = {
entry: './src/main.js',
output: {
path: path.resolve(__dirname, './dist'),
publicPath: '/dist/',
filename: 'build.js'
},
module: {
rules: [
{
test: /\.vue$/,
loader: 'vue-loader',
options: {
loaders: {
}
// other vue-loader options go here
}
},
{
test: /\.js$/,
loader: 'babel-loader',
exclude: /node_modules/
},
{
test: /\.css$/,
use: ExtractTextPlugin.extract({
fallback: "style-loader",
use: "css-loader"
})
},
{
test: /\.(png|jpg|gif|svg)$/,
loader: 'file-loader',
options: {
name: '[name].[ext]?[hash]'
}
}
]
},
resolve: {
alias: {
'vue$': 'vue/dist/vue.esm.js'
}
},
devServer: {
historyApiFallback: true,
noInfo: true
},
performance: {
hints: false
},
plugins: [new ExtractTextPlugin("main.css")],
devtool: '#eval-source-map'
}
if (process.env.NODE_ENV === 'production') {
module.exports.output.publicPath = '/<REPO_NAME>/dist/';
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({
sourceMap: true,
compress: {
warnings: false
}
}),*/
new webpack.LoaderOptionsPlugin({
minimize: true
})
])
}
Mind the <REPO_NAME> publicPath
entry in the production
part.
Next, I also had to update the links in my index.html
to use the dot-notation instead of just regular relative paths:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>listz-app</title>
<link rel="stylesheet" href="./dist/main.css">
</head>
<body>
<div id="app"></div>
<script src="./dist/build.js"></script>
</body>
</html>
This configuration works to deploy Vue-cli 2.0
webapplication to Github Pages.
publicPath
variable depending onprocess.env.NODE_ENV
. – Catima