Giter Club home page Giter Club logo

question-answer's Introduction

question-answer

question-answer's People

Contributors

xxxmrg avatar

Watchers

James Cloos avatar  avatar

question-answer's Issues

webpack 多页面配置时的一个问题

在学习 ICG 的时候参考过月影团长的示例代码,其代码就采用了很巧妙的方式来配置 webpack 最终可以得到一个很适合做 demo 的多页面应用,同时可以做到一次配置,可以自动 watch 并打包新添加到 entry 文件夹下的新代码。

仔细参考了其 webpack.config.js,在实际使用的时候遇到了一个问题,在 html 文件中如果直接采用相对路径来引用 js 文件,那么得到的文件实际上是并没有经过 webpack 处理的,也就是无法 import 所有 npm package,但是却并不会发生 404,会让人觉得文件是正确引入的,因此很难找到问题的源头。

排查了所有配置之后发现一直忽略了 output.publicPath 这个配置字段,一直以为它只与 build 之后的文件配置相关,其真正作用是用来标示打包后的文件的资源引用路径,最重要的,这个路径同样也是 webpack-dev-server 启动后的资源引用路径。 更多关于该配置,参考官方文档

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.