@vixoniccom/module-packager 2.4.1 → 2.4.3-dev.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.babelrc +3 -3
- package/.eslintrc +2 -2
- package/CHANGELOG.md +98 -86
- package/electron.js +45 -45
- package/index.html +64 -64
- package/main.js +182 -182
- package/package.json +108 -107
- package/tsconfig.json +15 -15
- package/webpack.config.js +162 -162
package/webpack.config.js
CHANGED
|
@@ -1,162 +1,162 @@
|
|
|
1
|
-
'use strict'
|
|
2
|
-
|
|
3
|
-
const CleanWebpackPlugin = require('clean-webpack-plugin')
|
|
4
|
-
const CopyWebpackPlugin = require('copy-webpack-plugin')
|
|
5
|
-
const HtmlWebpackPlugin = require('html-webpack-plugin')
|
|
6
|
-
const webpack = require('webpack')
|
|
7
|
-
const path = require('path')
|
|
8
|
-
const _ = require('lodash')
|
|
9
|
-
const fs = require('fs')
|
|
10
|
-
|
|
11
|
-
module.exports = (options) => {
|
|
12
|
-
if (options.target === 'web') {
|
|
13
|
-
options.externals = [...(options.externals || []), 'electron']
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
let tsconfigPath = fs.existsSync(path.join(options.src, '..', 'tsconfig.json')) ? path.join(options.src, '..', 'tsconfig.json') : path.join(__dirname, 'tsconfig.json')
|
|
17
|
-
const typescriptPath = path.join(options.src, '..', 'node_modules', 'typescript', '/')
|
|
18
|
-
const typescript = fs.existsSync(typescriptPath) ? path.join(__dirname, path.relative(__dirname, typescriptPath), '/') : 'typescript'
|
|
19
|
-
|
|
20
|
-
let exclude = options.mode === 'watch'
|
|
21
|
-
? [path.join(options.src, 'static'), path.join(options.src, 'test')]
|
|
22
|
-
: [path.resolve(options.src, 'static'), path.resolve(options.src, 'test')]
|
|
23
|
-
|
|
24
|
-
let config = {
|
|
25
|
-
context: __dirname,
|
|
26
|
-
entry: ['babel-polyfill', path.resolve(options.src, 'main')],
|
|
27
|
-
output: {
|
|
28
|
-
path: path.resolve(options.build),
|
|
29
|
-
filename: 'main.js'
|
|
30
|
-
},
|
|
31
|
-
node: {
|
|
32
|
-
__dirname: options.mode === 'watch',
|
|
33
|
-
fs: 'empty',
|
|
34
|
-
net: 'empty',
|
|
35
|
-
tls: 'empty'
|
|
36
|
-
},
|
|
37
|
-
resolve: {
|
|
38
|
-
extensions: ['.ts', '.tsx', '.js', '.jsx'],
|
|
39
|
-
modules: [
|
|
40
|
-
'node_modules',
|
|
41
|
-
'src',
|
|
42
|
-
'static'
|
|
43
|
-
]
|
|
44
|
-
},
|
|
45
|
-
module: {
|
|
46
|
-
loaders: [
|
|
47
|
-
{
|
|
48
|
-
test: /\.json$/,
|
|
49
|
-
exclude: exclude,
|
|
50
|
-
loader: 'json-loader'
|
|
51
|
-
},
|
|
52
|
-
{
|
|
53
|
-
test: /\.(j|t)sx?$/,
|
|
54
|
-
include: [path.resolve(options.src)],
|
|
55
|
-
exclude: exclude,
|
|
56
|
-
loaders: [
|
|
57
|
-
{
|
|
58
|
-
loader: 'babel-loader?babelrc=false&extends=' + path.join(__dirname, '/.babelrc')
|
|
59
|
-
},
|
|
60
|
-
{
|
|
61
|
-
loader: 'awesome-typescript-loader',
|
|
62
|
-
options: {
|
|
63
|
-
configFileName: tsconfigPath,
|
|
64
|
-
transpileOnly: options.transpileOnly,
|
|
65
|
-
compiler: typescript
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
]
|
|
69
|
-
},
|
|
70
|
-
{
|
|
71
|
-
test: /\.scss$/,
|
|
72
|
-
exclude: exclude,
|
|
73
|
-
loaders: ['style', 'css', 'sass']
|
|
74
|
-
},
|
|
75
|
-
{
|
|
76
|
-
test: /\.css$/,
|
|
77
|
-
exclude: exclude,
|
|
78
|
-
loader: 'style-loader!css-loader'
|
|
79
|
-
},
|
|
80
|
-
{
|
|
81
|
-
test: /\.(png|jpg|jpeg|gif|svg|woff|woff2|ttf|eot|mp4)$/,
|
|
82
|
-
exclude: exclude,
|
|
83
|
-
loader: 'file-loader'
|
|
84
|
-
},
|
|
85
|
-
{
|
|
86
|
-
test: /\.html$/,
|
|
87
|
-
loader: 'raw-loader'
|
|
88
|
-
}
|
|
89
|
-
]
|
|
90
|
-
},
|
|
91
|
-
externals: (context, request, callback) => {
|
|
92
|
-
if (_.indexOf(options.externals, request) !== -1) {
|
|
93
|
-
if (options.mode !== 'watch' || request === 'electron') {
|
|
94
|
-
return callback(null, "require('" + request + "')")
|
|
95
|
-
} else {
|
|
96
|
-
return callback(null, "require('" + path.resolve(options.src, '..', 'node_modules', request).replace(/\\/g, '\\\\') + "')")
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
callback()
|
|
100
|
-
},
|
|
101
|
-
plugins: [
|
|
102
|
-
new CopyWebpackPlugin([{ from: path.resolve(options.src, 'static'), to: 'static/' }], { copyUnmodified: true }),
|
|
103
|
-
new HtmlWebpackPlugin({
|
|
104
|
-
inject: 'head',
|
|
105
|
-
template: path.resolve(options.src, 'index.html')
|
|
106
|
-
}),
|
|
107
|
-
new webpack.LoaderOptionsPlugin({
|
|
108
|
-
options: {
|
|
109
|
-
test: /\.tsx?$/,
|
|
110
|
-
ts: {
|
|
111
|
-
compiler: 'typescript',
|
|
112
|
-
configFileName: 'tsconfig.json'
|
|
113
|
-
},
|
|
114
|
-
tslint: {
|
|
115
|
-
emitErrors: true,
|
|
116
|
-
failOnHint: true
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
})
|
|
120
|
-
],
|
|
121
|
-
target: options.target
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
if (options.mode === 'watch') {
|
|
125
|
-
config.entry.unshift(`webpack-dev-server/client?http://localhost:${options.port}/`, 'webpack/hot/dev-server', path.resolve(options.src, 'index.html'))
|
|
126
|
-
config.plugins.unshift(new CopyWebpackPlugin([{ from: path.resolve(options.src, 'test'), to: 'test/' }], { copyUnmodified: true }))
|
|
127
|
-
config.plugins.unshift(new webpack.HotModuleReplacementPlugin())
|
|
128
|
-
config.output.publicPath = `http://localhost:${options.port}/`
|
|
129
|
-
config.devtool = 'source-map'
|
|
130
|
-
config.devServer = {
|
|
131
|
-
contentBase: path.resolve(options.src),
|
|
132
|
-
publicPath: `http://localhost:${options.port}/`,
|
|
133
|
-
inline: true
|
|
134
|
-
}
|
|
135
|
-
} else {
|
|
136
|
-
config.plugins.unshift(
|
|
137
|
-
new CleanWebpackPlugin([path.basename(options.build), path.basename(options.build) + '.zip'], {
|
|
138
|
-
root: path.resolve(options.build, '..'),
|
|
139
|
-
verbose: false
|
|
140
|
-
}),
|
|
141
|
-
new webpack.DefinePlugin({
|
|
142
|
-
'process.env': {
|
|
143
|
-
NODE_ENV: JSON.stringify('production')
|
|
144
|
-
}
|
|
145
|
-
}),
|
|
146
|
-
new webpack.optimize.UglifyJsPlugin({
|
|
147
|
-
compress: {
|
|
148
|
-
warnings: false
|
|
149
|
-
},
|
|
150
|
-
mangle: true,
|
|
151
|
-
minimize: true,
|
|
152
|
-
comments: false
|
|
153
|
-
})
|
|
154
|
-
)
|
|
155
|
-
|
|
156
|
-
if (options.mode === 'run') {
|
|
157
|
-
config.plugins.unshift(new CopyWebpackPlugin([{ from: path.resolve(options.src, 'test'), to: 'test/' }], { copyUnmodified: true }))
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
return config
|
|
162
|
-
}
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
const CleanWebpackPlugin = require('clean-webpack-plugin')
|
|
4
|
+
const CopyWebpackPlugin = require('copy-webpack-plugin')
|
|
5
|
+
const HtmlWebpackPlugin = require('html-webpack-plugin')
|
|
6
|
+
const webpack = require('webpack')
|
|
7
|
+
const path = require('path')
|
|
8
|
+
const _ = require('lodash')
|
|
9
|
+
const fs = require('fs')
|
|
10
|
+
|
|
11
|
+
module.exports = (options) => {
|
|
12
|
+
if (options.target === 'web') {
|
|
13
|
+
options.externals = [...(options.externals || []), 'electron']
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
let tsconfigPath = fs.existsSync(path.join(options.src, '..', 'tsconfig.json')) ? path.join(options.src, '..', 'tsconfig.json') : path.join(__dirname, 'tsconfig.json')
|
|
17
|
+
const typescriptPath = path.join(options.src, '..', 'node_modules', 'typescript', '/')
|
|
18
|
+
const typescript = fs.existsSync(typescriptPath) ? path.join(__dirname, path.relative(__dirname, typescriptPath), '/') : 'typescript'
|
|
19
|
+
|
|
20
|
+
let exclude = options.mode === 'watch'
|
|
21
|
+
? [path.join(options.src, 'static'), path.join(options.src, 'test')]
|
|
22
|
+
: [path.resolve(options.src, 'static'), path.resolve(options.src, 'test')]
|
|
23
|
+
|
|
24
|
+
let config = {
|
|
25
|
+
context: __dirname,
|
|
26
|
+
entry: ['babel-polyfill', path.resolve(options.src, 'main')],
|
|
27
|
+
output: {
|
|
28
|
+
path: path.resolve(options.build),
|
|
29
|
+
filename: 'main.js'
|
|
30
|
+
},
|
|
31
|
+
node: {
|
|
32
|
+
__dirname: options.mode === 'watch',
|
|
33
|
+
fs: 'empty',
|
|
34
|
+
net: 'empty',
|
|
35
|
+
tls: 'empty'
|
|
36
|
+
},
|
|
37
|
+
resolve: {
|
|
38
|
+
extensions: ['.ts', '.tsx', '.js', '.jsx'],
|
|
39
|
+
modules: [
|
|
40
|
+
'node_modules',
|
|
41
|
+
'src',
|
|
42
|
+
'static'
|
|
43
|
+
]
|
|
44
|
+
},
|
|
45
|
+
module: {
|
|
46
|
+
loaders: [
|
|
47
|
+
{
|
|
48
|
+
test: /\.json$/,
|
|
49
|
+
exclude: exclude,
|
|
50
|
+
loader: 'json-loader'
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
test: /\.(j|t)sx?$/,
|
|
54
|
+
include: [path.resolve(options.src)],
|
|
55
|
+
exclude: exclude,
|
|
56
|
+
loaders: [
|
|
57
|
+
{
|
|
58
|
+
loader: 'babel-loader?babelrc=false&extends=' + path.join(__dirname, '/.babelrc')
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
loader: 'awesome-typescript-loader',
|
|
62
|
+
options: {
|
|
63
|
+
configFileName: tsconfigPath,
|
|
64
|
+
transpileOnly: options.transpileOnly,
|
|
65
|
+
compiler: typescript
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
]
|
|
69
|
+
},
|
|
70
|
+
{
|
|
71
|
+
test: /\.scss$/,
|
|
72
|
+
exclude: exclude,
|
|
73
|
+
loaders: ['style', 'css', 'sass']
|
|
74
|
+
},
|
|
75
|
+
{
|
|
76
|
+
test: /\.css$/,
|
|
77
|
+
exclude: exclude,
|
|
78
|
+
loader: 'style-loader!css-loader'
|
|
79
|
+
},
|
|
80
|
+
{
|
|
81
|
+
test: /\.(png|jpg|jpeg|gif|svg|woff|woff2|ttf|eot|mp4)$/,
|
|
82
|
+
exclude: exclude,
|
|
83
|
+
loader: 'file-loader'
|
|
84
|
+
},
|
|
85
|
+
{
|
|
86
|
+
test: /\.html$/,
|
|
87
|
+
loader: 'raw-loader'
|
|
88
|
+
}
|
|
89
|
+
]
|
|
90
|
+
},
|
|
91
|
+
externals: (context, request, callback) => {
|
|
92
|
+
if (_.indexOf(options.externals, request) !== -1) {
|
|
93
|
+
if (options.mode !== 'watch' || request === 'electron') {
|
|
94
|
+
return callback(null, "require('" + request + "')")
|
|
95
|
+
} else {
|
|
96
|
+
return callback(null, "require('" + path.resolve(options.src, '..', 'node_modules', request).replace(/\\/g, '\\\\') + "')")
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
callback()
|
|
100
|
+
},
|
|
101
|
+
plugins: [
|
|
102
|
+
new CopyWebpackPlugin([{ from: path.resolve(options.src, 'static'), to: 'static/' }], { copyUnmodified: true }),
|
|
103
|
+
new HtmlWebpackPlugin({
|
|
104
|
+
inject: 'head',
|
|
105
|
+
template: path.resolve(options.src, 'index.html')
|
|
106
|
+
}),
|
|
107
|
+
new webpack.LoaderOptionsPlugin({
|
|
108
|
+
options: {
|
|
109
|
+
test: /\.tsx?$/,
|
|
110
|
+
ts: {
|
|
111
|
+
compiler: 'typescript',
|
|
112
|
+
configFileName: 'tsconfig.json'
|
|
113
|
+
},
|
|
114
|
+
tslint: {
|
|
115
|
+
emitErrors: true,
|
|
116
|
+
failOnHint: true
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
})
|
|
120
|
+
],
|
|
121
|
+
target: options.target
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
if (options.mode === 'watch') {
|
|
125
|
+
config.entry.unshift(`webpack-dev-server/client?http://localhost:${options.port}/`, 'webpack/hot/dev-server', path.resolve(options.src, 'index.html'))
|
|
126
|
+
config.plugins.unshift(new CopyWebpackPlugin([{ from: path.resolve(options.src, 'test'), to: 'test/' }], { copyUnmodified: true }))
|
|
127
|
+
config.plugins.unshift(new webpack.HotModuleReplacementPlugin())
|
|
128
|
+
config.output.publicPath = `http://localhost:${options.port}/`
|
|
129
|
+
config.devtool = 'source-map'
|
|
130
|
+
config.devServer = {
|
|
131
|
+
contentBase: path.resolve(options.src),
|
|
132
|
+
publicPath: `http://localhost:${options.port}/`,
|
|
133
|
+
inline: true
|
|
134
|
+
}
|
|
135
|
+
} else {
|
|
136
|
+
config.plugins.unshift(
|
|
137
|
+
new CleanWebpackPlugin([path.basename(options.build), path.basename(options.build) + '.zip'], {
|
|
138
|
+
root: path.resolve(options.build, '..'),
|
|
139
|
+
verbose: false
|
|
140
|
+
}),
|
|
141
|
+
new webpack.DefinePlugin({
|
|
142
|
+
'process.env': {
|
|
143
|
+
NODE_ENV: JSON.stringify('production')
|
|
144
|
+
}
|
|
145
|
+
}),
|
|
146
|
+
new webpack.optimize.UglifyJsPlugin({
|
|
147
|
+
compress: {
|
|
148
|
+
warnings: false
|
|
149
|
+
},
|
|
150
|
+
mangle: true,
|
|
151
|
+
minimize: true,
|
|
152
|
+
comments: false
|
|
153
|
+
})
|
|
154
|
+
)
|
|
155
|
+
|
|
156
|
+
if (options.mode === 'run') {
|
|
157
|
+
config.plugins.unshift(new CopyWebpackPlugin([{ from: path.resolve(options.src, 'test'), to: 'test/' }], { copyUnmodified: true }))
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
return config
|
|
162
|
+
}
|