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

npm run build: Change publicPath from '/dist/' to './dist/' ? #71

Closed
FilipQL opened this issue Feb 18, 2017 · 4 comments
Closed

npm run build: Change publicPath from '/dist/' to './dist/' ? #71

FilipQL opened this issue Feb 18, 2017 · 4 comments

Comments

@FilipQL
Copy link

FilipQL commented Feb 18, 2017

I've started a thread about this on Vue-forum: https://forum.vuejs.org/t/vue-cli-webpack-production-images-vis-icons-are-not-loaded-where-to-import-css/6647/3

I am using Vue-cli [Webpack] and I have installed Vis.js. In App.vue I have added (imported) vis.css:

<style>
    @import "../node_modules/vis/dist/vis.css";
    ...
</style>

When I run npm run dev - everything works fine, all Vis icons are loaded (displayed), but when I run npm run build - when I open the app in the browser - Vis icons are missing and I am getting the following errors:

ovs mesh google chrome 2017-02-16 23 27 34

In webpack.config.js when I changed publicPath from '/dist/' to './dist/' - after running the npm run build command, everything works fine.

Now, I'm not sure whether it is a good idea to have publicPath: './dist/' by default when we are running only the npm run build command (and when we run npm run dev - then it should be just '/dist/').

@zcong1993
Copy link

zcong1993 commented Feb 24, 2017

maybe you can try this,
change publicPath to './dist/' when env is production

if (process.env.NODE_ENV === 'production') {
  // change publicPath to './dist/' when env is production
  module.exports.output.publicPath = './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
    })
  ])

@FilipQL
Copy link
Author

FilipQL commented Mar 1, 2017

@zcong1993 Tested, it works, thanks!

@oigordantas
Copy link

thanks

@zcong1993
Copy link

@vanydiah I think this vue-cli is much more modern to start new vue project, you can give a try.

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

4 participants