-
Notifications
You must be signed in to change notification settings - Fork 22
/
webpack.release.dev.config.js
110 lines (108 loc) · 2.73 KB
/
webpack.release.dev.config.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
const path = require('path');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const CopyPlugin = require('copy-webpack-plugin');
const ESLintPlugin = require('eslint-webpack-plugin');
const devMode = process.env.NODE_ENV !== 'production';
const integrationTarget = process.env.TARGET;
const integrationTargetUppercase = integrationTarget.charAt(0).toUpperCase() + integrationTarget.slice(1);
const entryClassName = `CatBlocks${integrationTargetUppercase}`;
const entryFile = `${entryClassName}.ts`;
module.exports = {
mode: 'production',
optimization: {
minimize: !devMode
},
entry: path.join(__dirname, 'src/library/ts/', entryFile),
output: {
filename: 'CatBlocks.js',
path: path.resolve(__dirname, 'dist'),
library: {
name: 'CatBlocks',
type: 'var',
export: entryClassName
}
},
resolve: {
extensions: ['.tsx', '.ts', '.js', '.json']
},
module: {
rules: [
{
test: /\.tsx?$/,
use: 'ts-loader',
exclude: /node_modules/
},
{
test: /\.js$/,
loader: 'babel-loader',
exclude: /node_modules/
},
{
test: /\.scss$/,
use: [
MiniCssExtractPlugin.loader,
'css-loader',
{
loader: 'postcss-loader',
options: {
postcssOptions: {
plugins: () => [
require('autoprefixer')
]
}
}
},
'sass-loader'
]
}
]
},
plugins: [
new ESLintPlugin({
fix: true
}),
new HtmlWebpackPlugin({
template: path.join(__dirname, 'src/library/html/release.html'),
filename: 'index.html',
hash: true
}),
new MiniCssExtractPlugin({
// Options similar to the same options in webpackOptions.output
// all options are optional
filename: '[name].css',
chunkFilename: '[id].css',
ignoreOrder: false, // Enable to remove warnings about conflicting order
}),
new CopyPlugin({
patterns: [
{ from: 'assets', to: 'media' },
{ from: 'node_modules/blockly/media', to: 'media' },
{ from: 'i18n/json', to: 'i18n' },
{ from: 'test/share', to: 'assets/share' },
{ from: 'favicon.ico', to: 'favicon.ico' }
]
})
],
devtool: 'source-map',
devServer: {
hot: true,
compress: !devMode,
host: '0.0.0.0',
port: 8080,
static: {
directory: path.join(__dirname, 'dist'),
serveIndex: true
},
devMiddleware: {
writeToDisk: !devMode
},
client: {
overlay: {
errors: true,
warnings: false,
}
}
},
target: 'web'
};