-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.app.config.js
97 lines (87 loc) · 2.68 KB
/
webpack.app.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
/* eslint-env node */
/* eslint-disable import/no-commonjs,import/no-nodejs-modules */
const webpack = require("webpack");
const merge = require("webpack-merge");
const path = require("path");
const CopyWebpackPlugin = require("copy-webpack-plugin");
const FriendlyErrorsPlugin = require("friendly-errors-webpack-plugin");
const { VueLoaderPlugin } = require("vue-loader");
const HtmlWebpackPlugin = require('html-webpack-plugin');
if (!process.env.NODE_ENV) {
process.env.NODE_ENV =
process.argv.indexOf("-p") !== -1 ? "production" : "development";
}
const mode = process.env.NODE_ENV;
const ENTRY_DIR = '/client_src';
const OUTPUT_DIR = '/app_src/main-win/client';
const nodeModules = path.resolve(__dirname, 'node_modules');
const baseConfig = {
mode,
watch: true,
entry: {
"main": path.join(__dirname, ENTRY_DIR, 'main.js'),
},
output: {
filename: "[name].bundle.js",
path: path.join(__dirname, OUTPUT_DIR),
publicPath: ""
},
module: {
rules: [
{
test: /\.m?js$/,
exclude: /(node_modules|bower_components)/,
use: {
loader: 'babel-loader',
options: {
presets: ['@babel/preset-env']
}
}
},
{
test: /\.vue$/,
loader: "vue-loader",
include: path.join(__dirname, ENTRY_DIR),
options: {
loaders: {
scss: ["style-loader", "css-loader", "sass-loader"]
}
}
},
{
test: /\.scss$/,
loaders: ["style-loader", "css-loader", "sass-loader"]
},
{
test: /\.(png|jpg)$/,
loader: "url-loader",
},
{
test: /\.html$/,
loader: 'html-loader'
},
]
},
plugins: [
new webpack.DefinePlugin({
"process.env": {
NODE_ENV: JSON.stringify(process.env.NODE_ENV),
DEBUG_DEVTOOLS_RX: JSON.stringify(process.env.DEBUG_DEVTOOLS_RX)
}
}),
new VueLoaderPlugin(),
new HtmlWebpackPlugin({
title: 'PixiJs remoute helper',
filename: 'main.html',
template: path.join(__dirname, ENTRY_DIR, 'main.html'),
}),
]
};
let devConfig = baseConfig;
if (process.env.NODE_ENV === "development") {
devConfig = merge(baseConfig, {
devtool: "source-map",
plugins: [new FriendlyErrorsPlugin()]
});
}
module.exports = devConfig;