tauri/cli/tauri.js/webpack.config.js
Jacob Bolda 6a21965ff3
chore: add prettier for js formatting (#937)
* chore: add prettier for js/ts formatting

* fix lint-staged to object

* test commit

* format all

* lock file bump

* eslint extends prettier

This will let us skip rules in eslint that prettier can control. Prettier for styles, eslint for code errors.

* add prettier config

* roll back to what we had with eslint settings

* skip mutation observer

* add prettier typescript eslint

* run prettier in lint workflow

* format:check script

* turn off space before function in eslint

it is fighting with prettier

* fix dir in workflow

* remove semis

* add api to eslint

* shift eslint ignore comment after prettier format

* ignore errors that currently exist

* build:typevalidators

* replace was broken on typevalidator build

* try pushing up error

* format

* try removing working dir from eslint workflow

* try node 12

* fix indent in action

* bump eslint

* fix supposeded error and try another

* try breaking eslint

* try building in action

* adjust action paths again

* need dot

* remove build

* fix(tauri.js/eslint): escape glob *

* fix(tauri.js): ignore lint error

* Create prettier-taurijs.md

Co-authored-by: Noah Klayman <noahklayman@gmail.com>
2020-08-18 21:36:46 -05:00

82 lines
1.9 KiB
JavaScript

const path = require('path')
const nodeExternals = require('webpack-node-externals')
const CopyWebpackPlugin = require('copy-webpack-plugin')
module.exports = {
entry: {
'api/build': './src/api/build.ts',
'api/dev': './src/api/dev.ts',
'api/init': './src/api/init.ts',
'api/recipes': './src/api/recipes/index.ts',
'api/recipes/install': './src/api/recipes/install.ts',
'api/tauricon': './src/api/tauricon.ts',
'api/info': './src/api/info.ts',
'api/dependency-manager': './src/api/dependency-manager/index.ts',
'helpers/tauri-config': './src/helpers/tauri-config.ts',
'helpers/spawn': './src/helpers/spawn.ts'
},
mode: process.env.NODE_ENV || 'development',
devtool: 'source-map',
module: {
rules: [
{
test: /\.tsx?$/,
use: 'ts-loader',
exclude: /node_modules/
},
{
test: /(templates|api)[\\/].+\.js/,
use: 'raw-loader'
},
{
test: /\.toml?$/,
use: 'toml-loader'
}
]
},
node: false,
resolve: {
extensions: ['.ts', '.js']
},
output: {
library: 'tauri',
libraryTarget: 'umd',
filename: '[name].js',
path: path.resolve(__dirname, 'dist')
},
externals: [nodeExternals()],
target: 'node',
plugins: [
new CopyWebpackPlugin({
patterns: [
{
from: './src/types/config.validator.ts',
to: '../src/types/config.schema.json',
transform(content) {
return schemaParser('TauriConfigSchema', content.toString())
}
}
]
})
]
}
function schemaParser(schemaName, content) {
const lines = content.split('\n')
const output = []
for (const line of lines) {
if (line === `export const ${schemaName} = {`) {
output.push('{')
} else if (output.length) {
if (line === '};') {
output.push('}')
break
}
output.push(line)
}
}
return output.join('\n')
}