Skip to content

Commit

Permalink
fix(css): Use *.module.css convention instead of *.mcss
Browse files Browse the repository at this point in the history
  • Loading branch information
jourdain committed Nov 1, 2018
1 parent eacdce5 commit 55fda79
Show file tree
Hide file tree
Showing 36 changed files with 109 additions and 62 deletions.
25 changes: 15 additions & 10 deletions Documentation/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ module.exports = {
parallelWebpack: {
maxConcurrentWorkers: 2,
rootPath: path.resolve(path.join(__dirname, '..')),
headers: ["const autoprefixer = require('autoprefixer');"],
plugins: [],
rules: [
`
Expand All @@ -32,26 +31,33 @@ module.exports = {
use: [
{
loader: 'babel-loader',
options: {
presets: [["@babel/preset-env", { useBuiltIns: 'entry' }]]
},
},
],
},
{
test: /\\.mcss$/,
test: /\.css$/,
exclude: /\.module\.css$/,
use: [
{ loader: 'style-loader' },
{ loader: 'css-loader' },
{ loader: 'postcss-loader' },
],
},
{
test: /\.module\.css$/,
use: [
{ loader: 'style-loader' },
{
loader: 'css-loader',
options: {
localIdentName: '[name]-[local]_[sha512:hash:base32:5]',
localIdentName: '[name]-[local]_[sha512:hash:base64:5]',
modules: true,
},
},
{
loader: 'postcss-loader',
options: {
plugins: () => [autoprefixer('last 2 version', 'ie >= 10')],
},
},
{ loader: 'postcss-loader' },
],
},
{
Expand All @@ -69,7 +75,6 @@ module.exports = {
},
{ test: /\\.(png|jpg)$/, use: 'url-loader?limit=81920' },
{ test: /\\.html$/, loader: 'html-loader' },
{ test: /\\.css$/, use: ['style-loader', 'css-loader', 'postcss-loader'] },
{ test: /\\.cjson$/, loader: 'hson-loader' },
{ test: /\\.hson$/, loader: 'hson-loader' },
`,
Expand Down
6 changes: 4 additions & 2 deletions Documentation/content/docs/intro_vtk_as_es6_dependency.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,10 @@ $ npm install kw-web-suite --save-dev
``` js ./webpack.config.js
var path = require('path');
var webpack = require('webpack');
var vtkRules = require('vtk.js/Utilities/config/dependency.js').webpack.v2.rules;
var vtkRules = require('vtk.js/Utilities/config/dependency.js').webpack.core.rules;

// Optional if you want to load *.css and *.module.css files
// var cssRules = require('vtk.js/Utilities/config/dependency.js').webpack.css.rules;

var entry = path.join(__dirname, './src/index.js');
const sourcePath = path.join(__dirname, './src');
Expand All @@ -79,7 +82,6 @@ module.exports = {
},
module: {
rules: [
{ test: entry, loader: "expose-loader?MyWebApp" },
{ test: /\.html$/, loader: 'html-loader' },
].concat(vtkRules),
},
Expand Down
2 changes: 1 addition & 1 deletion Examples/Applications/GeometryViewer/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import {
ScalarMode,
} from 'vtk.js/Sources/Rendering/Core/Mapper/Constants';

import style from './GeometryViewer.mcss';
import style from './GeometryViewer.module.css';
import icon from '../../../Documentation/content/icon/favicon-96x96.png';

let autoInit = true;
Expand Down
2 changes: 1 addition & 1 deletion Examples/Applications/OBJViewer/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import vtkMTLReader from 'vtk.js/Sources/IO/Misc/MTLReader';
import vtkMapper from 'vtk.js/Sources/Rendering/Core/Mapper';
import vtkActor from 'vtk.js/Sources/Rendering/Core/Actor';

import style from './OBJViewer.mcss';
import style from './OBJViewer.module.css';

const iOS = /iPad|iPhone|iPod/.test(window.navigator.platform);
let autoInit = true;
Expand Down
2 changes: 1 addition & 1 deletion Examples/Applications/SceneExplorer/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import vtkHttpSceneLoader from 'vtk.js/Sources/IO/Core/HttpSceneLoader';
import vtkURLExtract from 'vtk.js/Sources/Common/Core/URLExtract';

import controlWidget from './SceneExplorerWidget';
import style from './SceneExplorer.mcss';
import style from './SceneExplorer.module.css';

const iOS = /iPad|iPhone|iPod/.test(window.navigator.platform);
let autoInit = true;
Expand Down
2 changes: 1 addition & 1 deletion Examples/Applications/SkyboxViewer/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import vtkSkyboxReader from 'vtk.js/Sources/IO/Misc/SkyboxReader';
import vtkURLExtract from 'vtk.js/Sources/Common/Core/URLExtract';
// import vtkMobileVR from 'vtk.js/Sources/Common/System/MobileVR';

import style from './SkyboxViewer.mcss';
import style from './SkyboxViewer.module.css';

// ----------------------------------------------
// Possible URL parameters to look for:
Expand Down
2 changes: 1 addition & 1 deletion Examples/Applications/TubesViewer/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import {
} from 'vtk.js/Sources/Rendering/Core/Mapper/Constants';
import { VaryRadius } from 'vtk.js/Sources/Filters/General/TubeFilter/Constants';

import style from './TubesViewer.mcss';
import style from './TubesViewer.module.css';
import icon from '../../../Documentation/content/icon/favicon-96x96.png';

let autoInit = true;
Expand Down
2 changes: 1 addition & 1 deletion Examples/Applications/VolumeViewer/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import vtkVolumeMapper from 'vtk.js/Sources/Rendering/Core/VolumeMapper';
import vtkXMLImageDataReader from 'vtk.js/Sources/IO/XML/XMLImageDataReader';
import vtkFPSMonitor from 'vtk.js/Sources/Interaction/UI/FPSMonitor';

import style from './VolumeViewer.mcss';
import style from './VolumeViewer.module.css';

let autoInit = true;
const userParams = vtkURLExtract.extractURLParameters();
Expand Down
2 changes: 1 addition & 1 deletion Examples/Geometry/DepthTest/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import 'vtk.js/Sources/Common/Core/DataArray';
import 'vtk.js/Sources/Common/Core/StringArray';
import 'vtk.js/Sources/Common/DataModel/PolyData';

import style from './style.mcss';
import style from './style.module.css';

function affine(val, inMin, inMax, outMin, outMax) {
return ((val - inMin) / (inMax - inMin)) * (outMax - outMin) + outMin;
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion Examples/Geometry/SpheresAndLabels/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import vtkRenderWindow from 'vtk.js/Sources/Rendering/Core/RenderWindow';
import vtkRenderWindowInteractor from 'vtk.js/Sources/Rendering/Core/RenderWindowInteractor';
import vtkRenderer from 'vtk.js/Sources/Rendering/Core/Renderer';

import style from './style.mcss';
import style from './style.module.css';

// ----------------------------------------------------------------------------
// Standard rendering code setup
Expand Down
2 changes: 1 addition & 1 deletion Sources/Interaction/UI/CornerAnnotation/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import macro from 'vtk.js/Sources/macro';
import style from 'vtk.js/Sources/Interaction/UI/CornerAnnotation/CornerAnnotation.mcss';
import style from 'vtk.js/Sources/Interaction/UI/CornerAnnotation/CornerAnnotation.module.css';

function noOp() {}

Expand Down
2 changes: 1 addition & 1 deletion Sources/Interaction/UI/FPSMonitor/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import macro from 'vtk.js/Sources/macro';
import style from 'vtk.js/Sources/Interaction/UI/FPSMonitor/FPSMonitor.mcss';
import style from 'vtk.js/Sources/Interaction/UI/FPSMonitor/FPSMonitor.module.css';

const noOp = Function.prototype;

Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion Sources/Interaction/UI/Slider/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import macro from 'vtk.js/Sources/macro';
import Constants from 'vtk.js/Sources/Interaction/UI/Slider/Constants';
import style from 'vtk.js/Sources/Interaction/UI/Slider/Slider.mcss';
import style from 'vtk.js/Sources/Interaction/UI/Slider/Slider.module.css';

// ----------------------------------------------------------------------------
// Helper methods
Expand Down
2 changes: 1 addition & 1 deletion Sources/Interaction/UI/VolumeController/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import svgLogo from 'vtk.js/Sources/Interaction/UI/Icons/Logo.svg';
import svgEdge from 'vtk.js/Sources/Interaction/UI/Icons/Contrast.svg';
import svgSpacing from 'vtk.js/Sources/Interaction/UI/Icons/Spacing.svg';

import style from 'vtk.js/Sources/Interaction/UI/VolumeController/VolumeController.mcss';
import style from 'vtk.js/Sources/Interaction/UI/VolumeController/VolumeController.module.css';

// ----------------------------------------------------------------------------
// Global structures
Expand Down
2 changes: 1 addition & 1 deletion Sources/Rendering/Misc/RenderWindowWithControlBar/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import macro from 'vtk.js/Sources/macro';
import vtkGenericRenderWindow from 'vtk.js/Sources/Rendering/Misc/GenericRenderWindow';
import style from 'vtk.js/Sources/Rendering/Misc/RenderWindowWithControlBar/RenderWindowWithControlBar.mcss';
import style from 'vtk.js/Sources/Rendering/Misc/RenderWindowWithControlBar/RenderWindowWithControlBar.module.css';

// Load basic classes for vtk() factory
import 'vtk.js/Sources/Common/Core/Points';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import vtkMapper from 'vtk.js/Sources/Rendering/Core/Mapper';
import vtkActor from 'vtk.js/Sources/Rendering/Core/Actor';

import controlWidget from './SceneControllerWidget';
import style from './SceneLoader.mcss';
import style from './SceneLoader.module.css';

const iOS = /iPad|iPhone|iPod/.test(window.navigator.platform);
let autoInit = true;
Expand Down
2 changes: 1 addition & 1 deletion Sources/Testing/Examples/WindTunnel/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import vtkOutlineFilter from 'vtk.js/Sources/Filters/General/OutlineFilter';
import vtkPolyData from 'vtk.js/Sources/Common/DataModel/PolyData';

import controlPanel from './controller.html';
import style from './windtunnel.mcss';
import style from './windtunnel.module.css';

// ----------------------------------------------------------------------------
// Standard rendering code setup
Expand Down
73 changes: 50 additions & 23 deletions Utilities/config/dependency.js
Original file line number Diff line number Diff line change
@@ -1,38 +1,29 @@
const autoprefixer = require('autoprefixer');

module.exports = {
webpack: {
v1: {
loaders: [
{
test: /\.glsl$/i,
loader: 'shader-loader',
},
{
test: /\.js$/,
include: /node_modules(\/|\\)vtk\.js(\/|\\)/,
loader: 'babel-loader?presets[]=env',
},
{
test: /\.worker\.js$/,
include: /node_modules(\/|\\)vtk\.js(\/|\\)/,
loader: 'babel-loader?inline=true&fallback=false',
},
],
},
v2: {
core: {
rules: [
{
test: /\.glsl$/i,
include: /node_modules(\/|\\)vtk\.js(\/|\\)/,
include: /vtk\.js/,
loader: 'shader-loader',
},
{
test: /\.js$/,
include: /node_modules(\/|\\)vtk\.js(\/|\\)/,
loader: 'babel-loader?presets[]=env',
include: /vtk\.js/,
use: [
{
loader: 'babel-loader',
options: {
presets: ['@babel/preset-env'],
},
},
],
},
{
test: /\.worker\.js$/,
include: /node_modules(\/|\\)vtk\.js(\/|\\)/,
include: /vtk\.js/,
use: [
{
loader: 'worker-loader',
Expand All @@ -42,5 +33,41 @@ module.exports = {
},
],
},
css: [
{
test: /\.css$/,
exclude: /\.module\.css$/,
use: [
'style-loader',
'css-loader',
{
loader: 'postcss-loader',
options: {
plugins: () => [autoprefixer('last 2 version', 'ie >= 10')],
},
},
],
},
{
test: /\.css$/,
include: /\.module\.css$/,
use: [
{ loader: 'style-loader' },
{
loader: 'css-loader',
options: {
localIdentName: '[name]-[local]_[sha512:hash:base64:5]',
modules: true,
},
},
{
loader: 'postcss-loader',
options: {
plugins: () => [autoprefixer('last 2 version', 'ie >= 10')],
},
},
],
},
],
},
};
1 change: 0 additions & 1 deletion Utilities/config/rules-examples.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
module.exports = [
{ test: /\.(png|jpg)$/, use: 'url-loader?limit=81920' },
{ test: /\.html$/, loader: 'html-loader' },
{ test: /\.css$/, use: ['style-loader', 'css-loader', 'postcss-loader'] },
{ test: /\.cjson$/, loader: 'hson-loader' },
{ test: /\.hson$/, loader: 'hson-loader' },
];
31 changes: 20 additions & 11 deletions Utilities/config/rules-vtk.js
Original file line number Diff line number Diff line change
@@ -1,31 +1,40 @@
const autoprefixer = require('autoprefixer');

module.exports = [
{
test: /\.glsl$/i,
loader: 'shader-loader',
},
{
test: /\.js$/,
loader: 'babel-loader',
use: [
{
loader: 'babel-loader',
options: {
presets: ['@babel/preset-env'],
},
},
],
},
{
test: /\.mcss$/,
test: /\.css$/,
exclude: /\.module\.css$/,
use: [
{ loader: 'style-loader' },
{ loader: 'css-loader' },
{ loader: 'postcss-loader' },
],
},
{
test: /\.module\.css$/,
use: [
{ loader: 'style-loader' },
{
loader: 'css-loader',
options: {
localIdentName: '[name]-[local]_[sha512:hash:base32:5]',
localIdentName: '[name]-[local]_[sha512:hash:base64:5]',
modules: true,
},
},
{
loader: 'postcss-loader',
options: {
plugins: () => [autoprefixer('last 2 version', 'ie >= 10')],
},
},
{ loader: 'postcss-loader' },
],
},
{
Expand Down
5 changes: 5 additions & 0 deletions postcss.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
const autoprefix = require('autoprefixer');

module.exports = {
plugins: [autoprefix],
};

0 comments on commit 55fda79

Please sign in to comment.