mirror of
https://github.com/balena-io/etcher.git
synced 2025-07-23 19:26:33 +00:00
Convert webpack.config.js to typescript
Change-type: patch
This commit is contained in:
parent
746ee50027
commit
e7f58fc7fa
61
npm-shrinkwrap.json
generated
61
npm-shrinkwrap.json
generated
@ -1092,6 +1092,12 @@
|
|||||||
"defer-to-connect": "^1.0.1"
|
"defer-to-connect": "^1.0.1"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"@types/anymatch": {
|
||||||
|
"version": "1.3.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/@types/anymatch/-/anymatch-1.3.1.tgz",
|
||||||
|
"integrity": "sha512-/+CRPXpBDpo2RK9C68N3b2cOvO0Cf5B9aPijHsoDQTHivnGSObdOF2BRQOYjojWTDy6nQvMjmqRXIxH55VjxxA==",
|
||||||
|
"dev": true
|
||||||
|
},
|
||||||
"@types/bindings": {
|
"@types/bindings": {
|
||||||
"version": "1.3.0",
|
"version": "1.3.0",
|
||||||
"resolved": "https://registry.npmjs.org/@types/bindings/-/bindings-1.3.0.tgz",
|
"resolved": "https://registry.npmjs.org/@types/bindings/-/bindings-1.3.0.tgz",
|
||||||
@ -1338,6 +1344,12 @@
|
|||||||
"integrity": "sha512-1OzrNb4RuAzIT7wHSsgZRlMBlNsJl+do6UblR7JMW4oB7bbR+uBEYtUh7gEc/jM84GGilh68lSOokyM/zNUlBA==",
|
"integrity": "sha512-1OzrNb4RuAzIT7wHSsgZRlMBlNsJl+do6UblR7JMW4oB7bbR+uBEYtUh7gEc/jM84GGilh68lSOokyM/zNUlBA==",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
|
"@types/source-list-map": {
|
||||||
|
"version": "0.1.2",
|
||||||
|
"resolved": "https://registry.npmjs.org/@types/source-list-map/-/source-list-map-0.1.2.tgz",
|
||||||
|
"integrity": "sha512-K5K+yml8LTo9bWJI/rECfIPrGgxdpeNbj+d53lwN4QjW1MCwlkhUms+gtdzigTeUyBr09+u8BwOIY3MXvHdcsA==",
|
||||||
|
"dev": true
|
||||||
|
},
|
||||||
"@types/styled-components": {
|
"@types/styled-components": {
|
||||||
"version": "4.1.8",
|
"version": "4.1.8",
|
||||||
"resolved": "https://registry.npmjs.org/@types/styled-components/-/styled-components-4.1.8.tgz",
|
"resolved": "https://registry.npmjs.org/@types/styled-components/-/styled-components-4.1.8.tgz",
|
||||||
@ -1356,6 +1368,12 @@
|
|||||||
"csstype": "^2.6.4"
|
"csstype": "^2.6.4"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"@types/tapable": {
|
||||||
|
"version": "1.0.5",
|
||||||
|
"resolved": "https://registry.npmjs.org/@types/tapable/-/tapable-1.0.5.tgz",
|
||||||
|
"integrity": "sha512-/gG2M/Imw7cQFp8PGvz/SwocNrmKFjFsm5Pb8HdbHkZ1K8pmuPzOX4VeVoiEecFCVf4CsN1r3/BRvx+6sNqwtQ==",
|
||||||
|
"dev": true
|
||||||
|
},
|
||||||
"@types/tmp": {
|
"@types/tmp": {
|
||||||
"version": "0.1.0",
|
"version": "0.1.0",
|
||||||
"resolved": "https://registry.npmjs.org/@types/tmp/-/tmp-0.1.0.tgz",
|
"resolved": "https://registry.npmjs.org/@types/tmp/-/tmp-0.1.0.tgz",
|
||||||
@ -1368,6 +1386,15 @@
|
|||||||
"integrity": "sha512-wHNBMnkoEBiRAd3s8KTKwIuO9biFtTf0LehITzBhSco+HQI0xkXZbLOD55SW3Aqw3oUkHstkm5SPv58yaAdFPQ==",
|
"integrity": "sha512-wHNBMnkoEBiRAd3s8KTKwIuO9biFtTf0LehITzBhSco+HQI0xkXZbLOD55SW3Aqw3oUkHstkm5SPv58yaAdFPQ==",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
|
"@types/uglify-js": {
|
||||||
|
"version": "3.0.4",
|
||||||
|
"resolved": "https://registry.npmjs.org/@types/uglify-js/-/uglify-js-3.0.4.tgz",
|
||||||
|
"integrity": "sha512-SudIN9TRJ+v8g5pTG8RRCqfqTMNqgWCKKd3vtynhGzkIIjxaicNAMuY5TRadJ6tzDu3Dotf3ngaMILtmOdmWEQ==",
|
||||||
|
"dev": true,
|
||||||
|
"requires": {
|
||||||
|
"source-map": "^0.6.1"
|
||||||
|
}
|
||||||
|
},
|
||||||
"@types/usb": {
|
"@types/usb": {
|
||||||
"version": "1.5.1",
|
"version": "1.5.1",
|
||||||
"resolved": "https://registry.npmjs.org/@types/usb/-/usb-1.5.1.tgz",
|
"resolved": "https://registry.npmjs.org/@types/usb/-/usb-1.5.1.tgz",
|
||||||
@ -1384,6 +1411,40 @@
|
|||||||
"@types/node": "*"
|
"@types/node": "*"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"@types/webpack": {
|
||||||
|
"version": "4.41.2",
|
||||||
|
"resolved": "https://registry.npmjs.org/@types/webpack/-/webpack-4.41.2.tgz",
|
||||||
|
"integrity": "sha512-DNMQOfEvwzWRRyp6Wy9QVCgJ3gkelZsuBE2KUD318dg95s9DKGiT5CszmmV58hq8jk89I9NClre48AEy1MWAJA==",
|
||||||
|
"dev": true,
|
||||||
|
"requires": {
|
||||||
|
"@types/anymatch": "*",
|
||||||
|
"@types/node": "*",
|
||||||
|
"@types/tapable": "*",
|
||||||
|
"@types/uglify-js": "*",
|
||||||
|
"@types/webpack-sources": "*",
|
||||||
|
"source-map": "^0.6.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"@types/webpack-node-externals": {
|
||||||
|
"version": "1.7.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/@types/webpack-node-externals/-/webpack-node-externals-1.7.0.tgz",
|
||||||
|
"integrity": "sha512-3EohijquPf5rtTvhAPzqbBWb6nPnUxkRxEHcggQxktyeN0/pLnwtZ9nRR6XBCG0R/5nLnGzFrUwQV+pqJPqHXQ==",
|
||||||
|
"dev": true,
|
||||||
|
"requires": {
|
||||||
|
"@types/webpack": "*"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"@types/webpack-sources": {
|
||||||
|
"version": "0.1.5",
|
||||||
|
"resolved": "https://registry.npmjs.org/@types/webpack-sources/-/webpack-sources-0.1.5.tgz",
|
||||||
|
"integrity": "sha512-zfvjpp7jiafSmrzJ2/i3LqOyTYTuJ7u1KOXlKgDlvsj9Rr0x7ZiYu5lZbXwobL7lmsRNtPXlBfmaUD8eU2Hu8w==",
|
||||||
|
"dev": true,
|
||||||
|
"requires": {
|
||||||
|
"@types/node": "*",
|
||||||
|
"@types/source-list-map": "*",
|
||||||
|
"source-map": "^0.6.1"
|
||||||
|
}
|
||||||
|
},
|
||||||
"@webassemblyjs/ast": {
|
"@webassemblyjs/ast": {
|
||||||
"version": "1.8.5",
|
"version": "1.8.5",
|
||||||
"resolved": "https://registry.npmjs.org/@webassemblyjs/ast/-/ast-1.8.5.tgz",
|
"resolved": "https://registry.npmjs.org/@webassemblyjs/ast/-/ast-1.8.5.tgz",
|
||||||
|
@ -20,7 +20,7 @@
|
|||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "make lint test sanity-checks",
|
"test": "make lint test sanity-checks",
|
||||||
"prettier": "prettier --config ./node_modules/resin-lint/config/.prettierrc --write \"lib/**/*.ts\" \"lib/**/*.tsx\"",
|
"prettier": "prettier --config ./node_modules/resin-lint/config/.prettierrc --write \"lib/**/*.ts\" \"lib/**/*.tsx\" \"webpack.config.ts\"",
|
||||||
"start": "./node_modules/.bin/electron .",
|
"start": "./node_modules/.bin/electron .",
|
||||||
"postshrinkwrap": "node ./scripts/clean-shrinkwrap.js",
|
"postshrinkwrap": "node ./scripts/clean-shrinkwrap.js",
|
||||||
"configure": "node-gyp configure",
|
"configure": "node-gyp configure",
|
||||||
@ -102,6 +102,7 @@
|
|||||||
"@types/request": "^2.48.4",
|
"@types/request": "^2.48.4",
|
||||||
"@types/semver": "^6.2.0",
|
"@types/semver": "^6.2.0",
|
||||||
"@types/tmp": "^0.1.0",
|
"@types/tmp": "^0.1.0",
|
||||||
|
"@types/webpack-node-externals": "^1.7.0",
|
||||||
"babel-loader": "^8.0.4",
|
"babel-loader": "^8.0.4",
|
||||||
"chalk": "^1.1.3",
|
"chalk": "^1.1.3",
|
||||||
"electron": "6.1.4",
|
"electron": "6.1.4",
|
||||||
|
1
typings/simple-progress-webpack-plugin/index.d.ts
vendored
Normal file
1
typings/simple-progress-webpack-plugin/index.d.ts
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
declare module 'simple-progress-webpack-plugin';
|
@ -1,131 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2017 balena.io
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License")
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
'use strict'
|
|
||||||
|
|
||||||
const _ = require('lodash')
|
|
||||||
const path = require('path')
|
|
||||||
const SimpleProgressWebpackPlugin = require('simple-progress-webpack-plugin')
|
|
||||||
const nodeExternals = require('webpack-node-externals')
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Don't webpack package.json as mixpanel & sentry tokens
|
|
||||||
* will be inserted in it after webpacking
|
|
||||||
*
|
|
||||||
* @param {*} packageJsonPath - Path for the package.json file
|
|
||||||
* @returns {void}
|
|
||||||
*
|
|
||||||
* @example webpack externals:
|
|
||||||
* [
|
|
||||||
* externalPackageJson('./package.json')
|
|
||||||
* ]
|
|
||||||
*/
|
|
||||||
const externalPackageJson = (packageJsonPath) => {
|
|
||||||
return (_context, request, callback) => {
|
|
||||||
if (_.endsWith(request, 'package.json')) {
|
|
||||||
return callback(null, `commonjs ${packageJsonPath}`)
|
|
||||||
}
|
|
||||||
return callback()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const commonConfig = {
|
|
||||||
mode: 'production',
|
|
||||||
optimization: {
|
|
||||||
minimize: false
|
|
||||||
},
|
|
||||||
module: {
|
|
||||||
rules: [
|
|
||||||
{
|
|
||||||
test: /\.jsx?$/,
|
|
||||||
include: [ path.resolve(__dirname, 'lib', 'gui') ],
|
|
||||||
use: {
|
|
||||||
loader: 'babel-loader',
|
|
||||||
options: {
|
|
||||||
presets: [
|
|
||||||
'@babel/preset-react',
|
|
||||||
[ '@babel/preset-env', { targets: { electron: '6' } } ]
|
|
||||||
],
|
|
||||||
plugins: [ '@babel/plugin-proposal-function-bind' ],
|
|
||||||
cacheDirectory: true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
test: /\.html$/,
|
|
||||||
use: 'html-loader'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
test: /\.tsx?$/,
|
|
||||||
use: 'ts-loader'
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
resolve: {
|
|
||||||
extensions: [ '.js', '.jsx', '.json', '.ts', '.tsx' ]
|
|
||||||
},
|
|
||||||
plugins: [
|
|
||||||
new SimpleProgressWebpackPlugin({
|
|
||||||
format: process.env.WEBPACK_PROGRESS || 'verbose'
|
|
||||||
})
|
|
||||||
],
|
|
||||||
output: {
|
|
||||||
path: path.join(__dirname, 'generated'),
|
|
||||||
filename: '[name].js'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const guiConfig = {
|
|
||||||
...commonConfig,
|
|
||||||
target: 'electron-renderer',
|
|
||||||
node: {
|
|
||||||
__dirname: true,
|
|
||||||
__filename: true
|
|
||||||
},
|
|
||||||
externals: [
|
|
||||||
nodeExternals(),
|
|
||||||
|
|
||||||
// '../../../package.json' because we are in 'lib/gui/app/index.html'
|
|
||||||
externalPackageJson('../../../package.json')
|
|
||||||
],
|
|
||||||
entry: {
|
|
||||||
gui: path.join(__dirname, 'lib', 'gui', 'app', 'app.ts')
|
|
||||||
},
|
|
||||||
devtool: 'source-map'
|
|
||||||
}
|
|
||||||
|
|
||||||
const etcherConfig = {
|
|
||||||
...commonConfig,
|
|
||||||
target: 'electron-main',
|
|
||||||
node: {
|
|
||||||
__dirname: false,
|
|
||||||
__filename: true
|
|
||||||
},
|
|
||||||
externals: [
|
|
||||||
nodeExternals(),
|
|
||||||
|
|
||||||
// '../package.json' because we are in 'generated/etcher.js'
|
|
||||||
externalPackageJson('../package.json')
|
|
||||||
],
|
|
||||||
entry: {
|
|
||||||
etcher: path.join(__dirname, 'lib', 'start.ts')
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
module.exports = [
|
|
||||||
guiConfig,
|
|
||||||
etcherConfig
|
|
||||||
]
|
|
122
webpack.config.ts
Normal file
122
webpack.config.ts
Normal file
@ -0,0 +1,122 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2017 balena.io
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License")
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import * as _ from 'lodash';
|
||||||
|
import * as path from 'path';
|
||||||
|
import * as SimpleProgressWebpackPlugin from 'simple-progress-webpack-plugin';
|
||||||
|
import * as nodeExternals from 'webpack-node-externals';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Don't webpack package.json as mixpanel & sentry tokens
|
||||||
|
* will be inserted in it after webpacking
|
||||||
|
*/
|
||||||
|
function externalPackageJson(packageJsonPath: string) {
|
||||||
|
return (
|
||||||
|
_context: string,
|
||||||
|
request: string,
|
||||||
|
callback: (error?: Error | null, result?: string) => void,
|
||||||
|
) => {
|
||||||
|
if (_.endsWith(request, 'package.json')) {
|
||||||
|
return callback(null, `commonjs ${packageJsonPath}`);
|
||||||
|
}
|
||||||
|
return callback();
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
const commonConfig = {
|
||||||
|
mode: 'production',
|
||||||
|
optimization: {
|
||||||
|
minimize: false,
|
||||||
|
},
|
||||||
|
module: {
|
||||||
|
rules: [
|
||||||
|
{
|
||||||
|
test: /\.jsx?$/,
|
||||||
|
include: [path.resolve(__dirname, 'lib', 'gui')],
|
||||||
|
use: {
|
||||||
|
loader: 'babel-loader',
|
||||||
|
options: {
|
||||||
|
presets: [
|
||||||
|
'@babel/preset-react',
|
||||||
|
['@babel/preset-env', { targets: { electron: '6' } }],
|
||||||
|
],
|
||||||
|
plugins: ['@babel/plugin-proposal-function-bind'],
|
||||||
|
cacheDirectory: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
test: /\.html$/,
|
||||||
|
use: 'html-loader',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
test: /\.tsx?$/,
|
||||||
|
use: 'ts-loader',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
resolve: {
|
||||||
|
extensions: ['.js', '.jsx', '.json', '.ts', '.tsx'],
|
||||||
|
},
|
||||||
|
plugins: [
|
||||||
|
new SimpleProgressWebpackPlugin({
|
||||||
|
format: process.env.WEBPACK_PROGRESS || 'verbose',
|
||||||
|
}),
|
||||||
|
],
|
||||||
|
output: {
|
||||||
|
path: path.join(__dirname, 'generated'),
|
||||||
|
filename: '[name].js',
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
const guiConfig = {
|
||||||
|
...commonConfig,
|
||||||
|
target: 'electron-renderer',
|
||||||
|
node: {
|
||||||
|
__dirname: true,
|
||||||
|
__filename: true,
|
||||||
|
},
|
||||||
|
externals: [
|
||||||
|
nodeExternals(),
|
||||||
|
|
||||||
|
// '../../../package.json' because we are in 'lib/gui/app/index.html'
|
||||||
|
externalPackageJson('../../../package.json'),
|
||||||
|
],
|
||||||
|
entry: {
|
||||||
|
gui: path.join(__dirname, 'lib', 'gui', 'app', 'app.ts'),
|
||||||
|
},
|
||||||
|
devtool: 'source-map',
|
||||||
|
};
|
||||||
|
|
||||||
|
const etcherConfig = {
|
||||||
|
...commonConfig,
|
||||||
|
target: 'electron-main',
|
||||||
|
node: {
|
||||||
|
__dirname: false,
|
||||||
|
__filename: true,
|
||||||
|
},
|
||||||
|
externals: [
|
||||||
|
nodeExternals(),
|
||||||
|
|
||||||
|
// '../package.json' because we are in 'generated/etcher.js'
|
||||||
|
externalPackageJson('../package.json'),
|
||||||
|
],
|
||||||
|
entry: {
|
||||||
|
etcher: path.join(__dirname, 'lib', 'start.ts'),
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
module.exports = [guiConfig, etcherConfig];
|
Loading…
x
Reference in New Issue
Block a user