diff --git a/builder.config.js b/builder.config.js index 1e0cf89..45a25f2 100644 --- a/builder.config.js +++ b/builder.config.js @@ -35,7 +35,7 @@ module.exports = { { input: 'libraries', output: 'lib', - type: 'other', + type: 'css', }, { input: 'manifest.json', diff --git a/src/builder/builders.js b/src/builder/builders.js index d2f9015..80dc809 100644 --- a/src/builder/builders.js +++ b/src/builder/builders.js @@ -45,7 +45,7 @@ const builder = async (path, outPath, fileType) => { /** * Compiles a file * @param {string} file - The input files path - * @param {'sass' | 'js' | 'html' | 'file'} fileType - The file type + * @param {'sass' | 'js' | 'html' | 'css' | 'file'} fileType - The file type */ const fileBuilder = async (file, outPath, fileType) => { const t0 = performance.now(); @@ -57,6 +57,7 @@ const fileBuilder = async (file, outPath, fileType) => { file = file.replace(sassExtension, '.min.css'); } + const path = file.split('/'); const fileName = path[path.length - 1]; @@ -75,7 +76,7 @@ const fileBuilder = async (file, outPath, fileType) => { /** * Compiles a string of data given its type. * @param {string} data - * @param {'sass' | 'js' | 'html' | 'file'} fileType + * @param {'sass' | 'js' | 'html' | 'css' | 'file'} fileType * @returns {Promise} The compiled data */ const compile = async (file, fileType) => { @@ -85,6 +86,7 @@ const compile = async (file, fileType) => { return data.css.toString(); case 'js': + case 'css': case 'html': return await minify(file).catch((err) => console.log('Error compiling file ' + file + ':' + err) @@ -105,9 +107,10 @@ const replacePaths = (data) => { data = data.replace(new RegExp(key, 'g'), '/' + config.paths[key]); }); - data = data.replace(sassExtension, '.min.css'); } + data = data.replace(new RegExp(sassExtension, 'g'), '.min.css'); + return data; }; diff --git a/src/builder/watch.js b/src/builder/watch.js index 8d60694..4b22183 100644 --- a/src/builder/watch.js +++ b/src/builder/watch.js @@ -25,7 +25,7 @@ watcher.on('change', async (path) => { if (config) { const fileType = path.split('.').pop(); - const outPath = join(process.cwd(), 'dist', config.output); + const outPath = join(distDir, config.output); await fileBuilder(path, outPath, fileType); }