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

t/ckeditor5-ui/144: Migrated the snippet adapter to PostCSS #687

Merged
merged 13 commits into from
Nov 30, 2017
Merged
6 changes: 2 additions & 4 deletions scripts/docs/snippet-adapter/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,11 @@
"dependencies": {
"@ckeditor/ckeditor5-dev-webpack-plugin": "^3.0.0",
"babel-minify-webpack-plugin": "^0.2.0",
"css-loader": "^0.28.7",
"extract-text-webpack-plugin": "^3.0.0",
"node-sass": "^4.5.3",
"raw-loader": "^0.5.1",
"sass-loader": "^6.0.6",
"postcss-loader": "^2.0.8",
"style-loader": "^0.18.2",
"webpack": "^3.6.0",
"webpack": "^3.8.1",
"webpack-sources": "1.0.1"
}
}
29 changes: 10 additions & 19 deletions scripts/docs/snippet-adapter/snippetadapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
const path = require( 'path' );
const fs = require( 'fs' );
const webpack = require( 'webpack' );
const { bundler } = require( '@ckeditor/ckeditor5-dev-utils' );
const { bundler, styles: { getPostCssConfig } } = require( '@ckeditor/ckeditor5-dev-utils' );
const CKEditorWebpackPlugin = require( '@ckeditor/ckeditor5-dev-webpack-plugin' );
const ExtractTextPlugin = require( 'extract-text-webpack-plugin' );
const BabelMinifyPlugin = require( 'babel-minify-webpack-plugin' );
Expand All @@ -22,18 +22,12 @@ module.exports = function snippetAdapter( data ) {

const snippetConfig = readSnippetConfig( data.snippetSource.js );
const outputPath = path.join( data.outputPath, data.snippetPath );
let sassImportPath;

if ( snippetConfig.sassImportPath ) {
sassImportPath = path.join( path.dirname( data.snippetSource.js ), snippetConfig.sassImportPath );
}

const webpackConfig = getWebpackConfig( {
entry: data.snippetSource.js,
outputPath,
language: snippetConfig.language,
minify: data.options.production,
sassImportPath
minify: data.options.production
} );

let promise;
Expand Down Expand Up @@ -133,21 +127,18 @@ function getWebpackConfig( config ) {
use: [ 'raw-loader' ]
},
{
test: /\.scss$/,
test: /\.css$/,
use: ExtractTextPlugin.extract( {
fallback: 'style-loader',
use: [
{
loader: 'css-loader',
options: {
minimize: config.minify
}
},
{
loader: 'sass-loader',
options: {
data: config.sassImportPath ? `@import '${ config.sassImportPath }';` : ''
}
loader: 'postcss-loader',
options: getPostCssConfig( {
themeImporter: {
themePath: require.resolve( '@ckeditor/ckeditor5-theme-lark' )
},
minify: config.minify
} )
}
]
} )
Expand Down