Coder Social home page Coder Social logo

CSS support? about vuepack HOT 6 CLOSED

egoist avatar egoist commented on June 24, 2024
CSS support?

from vuepack.

Comments (6)

egoist avatar egoist commented on June 24, 2024

Yep, because we didn't add a css-loader for .css file, but you can still use .css file and load it in a .vue component:

<style src="./css/app.css"></style>

from vuepack.

egoist avatar egoist commented on June 24, 2024

Oops, I think there's already loaders for .css https://github.com/egoist/vuepack/blob/master/template/build/webpack.dev.js#L23

What do you mean by "Webpack does not process them"?

from vuepack.

fallenpeace avatar fallenpeace commented on June 24, 2024

If you make a folder client/styles/, and add file style.css, add any rule. body { background: red }

npm run dev => style.css is never touched by webpack or compiled.
npm run build => style.css is never touched by webpack or compiled.

from vuepack.

egoist avatar egoist commented on June 24, 2024

Did you load it in your component?

from vuepack.

FrancosLab avatar FrancosLab commented on June 24, 2024

So including it via <style src="./css/app.css"></style> works, thank you! I was unaware of this syntax for .vue files.

A bug that I have ran into is that if you have background: url('../assets/image.png'); in app.css.

Webpack will find the file and process it, it works prefectly fine with npm run dev however with npm run build it gets converted to background: url(../assets/assets/image.png'); but the build path for the image assets/image.png, so the browser wont find the image because it gets compiled to the wrong folder.

from vuepack.

egoist avatar egoist commented on June 24, 2024

I've just flatten the dist directory, now it's ./dist instead of ./dist/assets, and a file-loader was added to support importing images and fonts in your app:

{
  test: /\.(ico|jpg|png|gif|eot|otf|webp|svg|ttf|woff|woff2)(\?.*)?$/,
  loader: 'file',
  query: {
    name: 'static/media/[name].[hash:8].[ext]'
  }
}

The path to static file you import will be ./dist/static/media/name.extension, and the index file will be ./dist/index.html, the bundled script ./dist/vendor.xxx.js and so on.

Now it should work when you run npm run build 😃

from vuepack.

Related Issues (20)

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.