forked from MotocalDevelopers/motocal
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.js
89 lines (85 loc) · 2.49 KB
/
webpack.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
const webpack = require('webpack');
const ExtractTextPlugin = require('extract-text-webpack-plugin');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const ManifestPlugin = require('webpack-manifest-plugin');
const path = require('path');
process.env.NODE_ENV = process.env.NODE_ENV || 'development';
const DEBUG = process.env.NODE_ENV === 'development' || process.env.NODE_ENV === undefined;
const devtool = DEBUG ? '#inline-source-map' : '#eval';
const fileName = DEBUG ? '[name]' : '[name]-[hash]';
const plugins = [
new ExtractTextPlugin({
filename: `${fileName}.css`,
disable: false,
allChunks: true
}),
new HtmlWebpackPlugin({
template: path.join(__dirname, 'public/index.html'),
inject: false,
favicon: path.join(__dirname, 'public/favicon.ico'),
minify: {
removeComments: true,
// collapseWhitespace: true,
removeRedundantAttributes: true,
useShortDoctype: true,
removeEmptyAttributes: true,
removeStyleLinkTypeAttributes: true,
keepClosingSlash: true,
// minifyJS: true,
// minifyCSS: true,
// minifyURLs: true,
},
ADSENSE_AD_CLIENT: JSON.stringify(process.env.ADSENSE_AD_CLIENT || ''),
ADSENSE_AD_SLOT_PC1: JSON.stringify(process.env.ADSENSE_AD_SLOT_PC1 || ''),
ADSENSE_AD_SLOT_PC2: JSON.stringify(process.env.ADSENSE_AD_SLOT_PC2 || ''),
ADSENSE_AD_SLOT_MOBILE: JSON.stringify(process.env.ADSENSE_AD_SLOT_MOBILE || ''),
}),
new webpack.DefinePlugin({
'process.env': {
NODE_ENV: JSON.stringify(process.env.NODE_ENV || 'development'),
GITHUB_API_TOKEN: JSON.stringify(process.env.GITHUB_API_TOKEN || ''),
},
}),
// new webpack.optimize.UglifyJsPlugin({
// compress: {
// screw_ie8: true, // React doesn't support IE8
// warnings: false,
// },
// mangle: {
// screw_ie8: true,
// },
// output: {
// comments: false,
// screw_ie8: true,
// },
// }),
new ManifestPlugin({
fileName: 'asset-manifest.json',
}),
];
module.exports = {
devtool: devtool,
entry: './src/content.js',
output: {
path: path.join(__dirname, 'dist'),
filename: `${fileName}.js`,
},
module: {
rules: [
{
test: /.jsx?$/,
exclude: /node_modules/,
loader: "babel-loader",
},
{
test: /.css?$/,
use: ExtractTextPlugin.extract({
fallback: "style-loader",
use: "css-loader",
publicPath: "/build"
})
}
],
},
plugins: plugins,
}