-
Notifications
You must be signed in to change notification settings - Fork 3
/
webpack.config.base.js
128 lines (121 loc) · 3.71 KB
/
webpack.config.base.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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
const path = require('path');
const webpack = require('webpack');
const { VueLoaderPlugin } = require('vue-loader');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const TerserPlugin = require('terser-webpack-plugin');
const CssMinimizerPlugin = require('css-minimizer-webpack-plugin');
const CopyWebpackPlugin = require('copy-webpack-plugin');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const pkg = require('./package.json');
const version = "1.0.8";
module.exports = {
mode: process.env.NODE_ENV,
context: __dirname + '/src',
entry:
{
'index': './index.js',
},
output: {
path: path.resolve(__dirname, 'dist'),
filename: `[name].js`,
},
resolve: {
extensions: ['.js', '.vue'],
alias: {
'@': path.resolve('src'),
}
},
module: {
rules: [{
test: /\.vue$/i,
loader: 'vue-loader',
},
{
test: /\.html$/i,
loader: 'html-loader',
},
{
test: /\.js$/,
loader: 'babel-loader',
exclude: /node_modules/,
},
{
test: /\.less$/,
use: [
'vue-style-loader',
'css-loader',
'less-loader'
]
},
{
test: /\.css$/i,
use: [
'style-loader', 'css-loader'
],
},
{
test: /\.scss$/,
use: [MiniCssExtractPlugin.loader, 'css-loader', 'sass-loader'],
},
{
test: /\.sass$/,
use: [MiniCssExtractPlugin.loader, 'css-loader', 'sass-loader?indentedSyntax'],
},
{
test: /\.(png|jpg|jpeg|gif|svg|ico)$/,
loader: 'file-loader',
options: {
esModule: false,
name: '[name].[ext]',
outputPath: 'images/',
emitFile: true
},
},
{
test: /\.(woff2|ttf|woff|eot)(\?v=\d+\.\d+\.\d+)?$/,
loader: 'file-loader',
options: {
name: '[name].[ext]',
outputPath: 'fonts/',
emitFile: true
},
}
],
},
plugins: [
new webpack.DefinePlugin({
'process.env.WACRM_VERSION': `"${version}"`,
'process.env.API': '"https://restsend.com"',
global: 'window',
}),
new VueLoaderPlugin(),
new MiniCssExtractPlugin({
filename: '[name].css',
}),
new HtmlWebpackPlugin(),
new CopyWebpackPlugin({
patterns: [
{ from: 'icons', to: 'icons' },
{ from: 'app/background.js', to: 'background.js' },
{ from: 'app/waext.js', to: 'waext.js' },
{ from: 'app/content.js', to: 'content.js' },
{
from: 'manifest.json', to: 'manifest.json',
transform: (content, absoluteFrom) => {
let cobj = JSON.parse(content.toString());
let store = 'chrome'
if (process.env.TARGET_STORE) {
store = process.env.TARGET_STORE
}
cobj["homepage_url"] = cobj["homepage_url"] + store
cobj["version"] = version;
if (process.env.NODE_ENV == "development") {
cobj["host_permissions"].push("http://*/wa/WhatsApp*");
}
return JSON.stringify(cobj, null, 2);
}
}
]
}),
],
};