diff --git a/package.json b/package.json index f9d740b..a6177bf 100644 --- a/package.json +++ b/package.json @@ -44,6 +44,7 @@ "less": "^2.7.1", "mkdirp": "^0.5.1", "nib": "^1.1.2", + "pug": "^2.0.0-beta11", "resolve": "^1.2.0", "rimraf": "^2.5.4", "sass-lookup": "^1.0.2", diff --git a/src/html/pug.js b/src/html/pug.js new file mode 100644 index 0000000..83135ad --- /dev/null +++ b/src/html/pug.js @@ -0,0 +1,31 @@ +import {SimpleCompilerBase} from '../compiler-base'; + +const inputMimeTypes = ['text/pug']; +let pug = null; + +/** + * @access private + */ +export default class PugCompiler extends SimpleCompilerBase { + constructor() { + super(); + this.compilerOptions.sourceMap = true; + } + + static getInputMimeTypes() { + return inputMimeTypes; + } + + compileSync(sourceCode, filePath) { + pug = pug || require('pug'); + let code = pug.render( + sourceCode, + Object.assign({ filename: filePath, cache: false }, this.compilerOptions)); + + return { code, mimeType: 'text/html' }; + } + + getCompilerVersion() { + return require('pug/package.json').version; + } +} diff --git a/src/html/vue.js b/src/html/vue.js index fc356d9..7e187ba 100644 --- a/src/html/vue.js +++ b/src/html/vue.js @@ -11,6 +11,7 @@ const mimeTypeToSimpleType = { 'text/typescript': 'ts', 'application/javascript': 'js', 'text/jade': 'jade', + 'text/pug': 'pug', 'text/less': 'less', 'text/sass': 'sass', 'text/scss': 'scss', diff --git a/src/main.js b/src/main.js index 9659be5..b2bcac7 100644 --- a/src/main.js +++ b/src/main.js @@ -8,6 +8,7 @@ const filenames = [ 'json/cson', 'html/inline-html', 'html/jade', + 'html/pug', 'html/vue', 'passthrough' ];