js: support shared styles via webpack inline

This commit is contained in:
Marcin Lulek 2018-10-30 15:25:17 +01:00
parent 2eadca530d
commit f525c01bb6
6 changed files with 27 additions and 23 deletions

View file

@ -17,5 +17,5 @@ module.exports = function(grunt) {
grunt.loadNpmTasks('grunt-contrib-jshint'); grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-contrib-copy'); grunt.loadNpmTasks('grunt-contrib-copy');
grunt.loadNpmTasks('grunt-webpack'); grunt.loadNpmTasks('grunt-webpack');
grunt.registerTask('default', ['less:production', 'less:components', 'concat:polymercss', 'copy', 'webpack', 'concat:dist']); grunt.registerTask('default', ['less:production', 'less:components', 'copy', 'webpack', 'concat:dist']);
}; };

View file

@ -1,8 +1,8 @@
{ {
"dirs": { "dirs": {
"css": { "css": {
"src":"rhodecode/public/css", "src": "rhodecode/public/css",
"dest":"rhodecode/public/css" "dest": "rhodecode/public/css"
}, },
"js": { "js": {
"src": "rhodecode/public/js/src", "src": "rhodecode/public/js/src",
@ -13,22 +13,21 @@
}, },
"copy": { "copy": {
"main": { "main": {
"expand": true, "files": [
"cwd": "node_modules/@webcomponents", {
"src": "webcomponentsjs/*.*", "expand": true,
"dest": "<%= dirs.js.dest %>/vendors" "cwd": "node_modules/@webcomponents",
"src": "webcomponentsjs/*.*",
"dest": "<%= dirs.js.dest %>/vendors"
},
{
"src": "<%= dirs.css.src %>/style-polymer.css",
"dest": "<%= dirs.js.dest %>/src/components/style-polymer.css"
}
]
} }
}, },
"concat": { "concat": {
"polymercss": {
"src": [
"<%= dirs.js.src %>/components/root-styles-prefix.html",
"<%= dirs.css.src %>/style-polymer.css",
"<%= dirs.js.src %>/components/root-styles-suffix.html"
],
"dest": "<%= dirs.js.dest %>/src/components/root-styles.gen.html",
"nonull": true
},
"dist": { "dist": {
"src": [ "src": [
"<%= dirs.js.node_modules %>/jquery/dist/jquery.min.js", "<%= dirs.js.node_modules %>/jquery/dist/jquery.min.js",

View file

@ -1,5 +1,5 @@
import '@polymer/iron-ajax/iron-ajax.js'; import '@polymer/iron-ajax/iron-ajax.js';
import './root-styles.gen.html'; import './shared-styles.js';
import './channelstream-connection/channelstream-connection.js'; import './channelstream-connection/channelstream-connection.js';
import './rhodecode-toast/rhodecode-toast.js'; import './rhodecode-toast/rhodecode-toast.js';
import './rhodecode-toggle/rhodecode-toggle.js'; import './rhodecode-toggle/rhodecode-toggle.js';

View file

@ -1,3 +0,0 @@
<dom-module id="shared-styles">
<template>
<style>

View file

@ -1,3 +0,0 @@
</style>
</template>
</dom-module>

View file

@ -0,0 +1,11 @@
const styleElement = document.createElement('dom-module');
import sharedCSS from 'raw-loader!./style-polymer.css';
styleElement.innerHTML =
`<template>
<style>
${sharedCSS}
</style>
</template>`;
styleElement.register('shared-styles');