1 Star 0 Fork 27

bing / sketch-meaxure

forked from hubzy / sketch-meaxure 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
webpack.skpm.config.js 1.49 KB
一键复制 编辑 原始数据 按行查看 历史
hubzy 提交于 2020-11-06 18:51 . dev update
'use strict';
let fs = require('fs');
let path = require('path');
let process = require('process');
/**
* Function that mutates original webpack config.
* Supports asynchronous changes when promise is returned.
*
* @param {object} config - original webpack config.
* @param {boolean} isPluginCommand - wether the config is for a plugin command or an asset
**/
module.exports = function (config, isPluginCommand) {
/** you can change config here **/
if (!isPluginCommand) return;
let debug = !!process.env.DEBUG;
if (!debug) clearMapFilesForProduction('sketch-meaxure.sketchplugin/Contents');
config.mode = debug ? 'development' : 'production';
config.entry = {
mark: './src/index.ts',
};
config.module = {
rules: [{
test: /\.tsx?$/,
use: 'ts-loader',
exclude: /node_modules/
}]
};
config.resolve = {
extensions: ['.tsx', '.ts', '.js']
}
// config.output = {
// path: path.resolve(__dirname, skpmConfig.main, 'Contents', 'Sketch'),
// filename: '[name]_bundle.js'
// }
}
function clearMapFilesForProduction(dir) {
fs.readdirSync(dir).forEach(file => {
let fullName = path.resolve(dir, file);
if (fs.statSync(fullName).isDirectory()) {
clearMapFilesForProduction(fullName);
return;
}
if (file.endsWith('.js.map')) {
console.log('remove js map file', file);
fs.unlinkSync(fullName);
}
})
}
JavaScript
1
https://gitee.com/binmes/sketch-meaxure.git
git@gitee.com:binmes/sketch-meaxure.git
binmes
sketch-meaxure
sketch-meaxure
master

搜索帮助