import os exclude_files = [ 'onedark.css', 'onelight.css', 'default-dark.css', 'default-light.css' ] exclude_folders = [ 'static' ] os.system('npm run build') for file in os.listdir('dist'): if file in exclude_files or file.endswith('.json') or file.endswith('.v'): os.remove('dist/' + file) with open('./dist/index.html', 'r', encoding='utf-8') as fp: html = fp.read() index = html.index('') html = html[:index] + '\n' + html[index:] new_html = [] for line in html.split('\n'): if 'const inputVcdFile =' in line: new_html.append("const inputVcdFile = 'test.json';") elif 'window.moduleName' in line: new_html.append("window.moduleName = 'test.module';") else: new_html.append(line.strip()) with open('./dist/index.html', 'w', encoding='utf-8') as fp: fp.write('\n'.join(new_html))