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

CSS support? #34

Closed
fallenpeace opened this issue Sep 8, 2016 · 6 comments
Closed

CSS support? #34

fallenpeace opened this issue Sep 8, 2016 · 6 comments

Comments

@fallenpeace
Copy link

fallenpeace commented Sep 8, 2016

Hi there! Awesome stuff with vuepack (vue 2). Already used it to push something to production.

On this new project I have to use regular .css files.

But when I place 'app.css' inside 'client/styles/app.css'

Webpack does not process them.

I've been comparing the webpack config files to another webpack files but I can not figure it out.

Please advice, thank you! I'm learning webpack so I'm really stump.

@egoist
Copy link
Owner

egoist commented Sep 9, 2016

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>

@egoist
Copy link
Owner

egoist commented Sep 9, 2016

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"?

@fallenpeace
Copy link
Author

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.

@egoist
Copy link
Owner

egoist commented Sep 9, 2016

Did you load it in your component?

@FrancosLab
Copy link

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.

@egoist
Copy link
Owner

egoist commented Sep 16, 2016

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 😃

@egoist egoist closed this as completed Sep 23, 2016
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

3 participants