-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathwebpack.config.js
115 lines (108 loc) · 2.67 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
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
var path = require('path');
var webpack = require('webpack');
var autoprefixer = require('autoprefixer');
var CopyPlugin = require('copy-webpack-plugin');
var CleanWebpackPlugin = require('clean-webpack-plugin').CleanWebpackPlugin;
var NodePolyfillPlugin = require('node-polyfill-webpack-plugin');
var mode = process.env.NODE_ENV.match(/prod/) ? 'production' : 'development';
var rules = [
{
test: /\.jsx?$/,
include: path.join(__dirname, 'src'),
use: {
loader: 'babel-loader',
options: {
cacheDirectory: true,
babelrc: false,
presets: [
[
'@babel/preset-env',
{ targets: { browsers: 'last 2 versions' } }
],
'@babel/preset-react'
]
}
}
},
{
test: /\.s?css$/,
use: [{
loader: "style-loader"
}, {
loader: "css-loader",
options: { url: false }
}, {
loader: "postcss-loader"
}, {
loader: "sass-loader"
}
]
}
];
var plugins = [];
plugins.push(new CleanWebpackPlugin({
plugins: ['app/**/*.*']
}));
plugins.push(new CopyPlugin({
patterns: [
{ from: 'static', to: '.' },
(/firefox/.test(process.env.SYNCMARX_MANIFEST)) ?
{
from: 'src/manifest-firefox.json',
to: './manifest.json',
} :
{
from: 'src/manifest.json',
to: './manifest.json'
}
]
}));
plugins.push(
autoprefixer
);
plugins.push(
new webpack.DefinePlugin({
PRODUCTION: mode === 'production',
'process.env.NODE_ENV': (mode === 'production') ? JSON.stringify('production') : JSON.stringify('development')
})
);
plugins.push(
new NodePolyfillPlugin({
// Note: Newer versions of the Dropbox SDK and cryptr libraries have a hard dependency on native Node.js libs
includeAliases: ['crypto','stream', 'Buffer']
})
);
plugins.push(
// Fix "process is not defined" error:
new webpack.ProvidePlugin({
process: 'process/browser',
}),
);
module.exports = {
mode: mode,
entry: {
app: './src/core/App.js',
settings: './src/core/Settings.jsx'
},
output: {
path: path.resolve(__dirname, 'App'),
filename: '[name].js',
publicPath: '/'
},
// Currently we need to add '.ts' to resolve.extensions array.
resolve: {
extensions: ['.tsx', '.ts', '.jsx', '.js', '.json', '.scss', '.css'],
modules: ['node_modules', 'src'],
fallback: { vm: false }
},
// Source maps support (or 'inline-source-map' also works)
devtool: (mode === 'production') ? undefined : 'inline-source-map',
// Add loader for .ts files.
module: {
rules: rules
},
plugins: plugins,
optimization: {
minimize: false
}
};