1 Star 0 Fork 0

Vue.js/vue-style-loader

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
MIT

vue-style-loader Build Status npm package

This is a fork based on style-loader. Similar to style-loader, you can chain it after css-loader to dynamically inject CSS into the document as style tags. However, since this is included as a dependency and used by default in vue-loader, in most cases you don't need to configure this loader yourself.

Options

  • manualInject (3.1.0+):

    Type: boolean. When importing the style from a non-vue-file, by default the style is injected as a side effect of the import. When manualInject is true, the imported style object exposes a __inject__ method, which can then be called manually at appropriate timing. If called on the server, the method expects one argument which is the ssrContext to attach styles to.

    import styles from 'styles.scss'
    
    export default {
      beforeCreate() { // or create a mixin for this purpose
        if(styles.__inject__) {
          styles.__inject__(this.$ssrContext)
        }
      }
    
      render() {
        return <div class={styles.heading}>Hello World</div>
      }
    }

    Note this behavior is enabled automatically when vue-style-loader is used on styles imported within a *.vue file. The option is only exposed for advanced usage.

  • ssrId (3.1.0+):

    Type: boolean. Add data-vue-ssr-id attribute to injected <style> tags even when not in Node.js. This can be used with pre-rendering (instead of SSR) to avoid duplicate style injection on hydration.

Differences from style-loader

Server-Side Rendering Support

When bundling with target: 'node', the styles in all rendered components are collected and exposed on the Vue render context object as context.styles, which you can simply inline into your markup's <head>. If you are building a Vue SSR app, you probably should use this loader for CSS imported from JavaScript files too.

Misc

  • Does not support url mode and reference counting mode. Also removed singleton and insertAt query options. It always automatically pick the style insertion mechanism that makes most sense. If you need these capabilities you should probably use the original style-loader instead.

  • Fixed the issue that root-relative URLs are interpreted against chrome:// urls and make source map URLs work for injected <style> tags in Chrome.

License

MIT

Copyright JS Foundation and other contributors Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

简介

💅 vue style loader module for webpack 展开 收起
JavaScript
MIT
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/vuejs/vue-style-loader.git
git@gitee.com:vuejs/vue-style-loader.git
vuejs
vue-style-loader
vue-style-loader
master

搜索帮助

Cb406eda 1850385 E526c682 1850385