This repository has been archived by the owner on Aug 21, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 21
/
Copy pathwebpack.config.js
61 lines (59 loc) · 1.69 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
const webpack = require('webpack');
const path = require('path');
const CleanWebpackPlugin = require("clean-webpack-plugin");
const CopyWebpackPlugin = require('copy-webpack-plugin');
const buildPath = path.resolve(__dirname, 'dist');
const ConcatPlugin = require('webpack-concat-plugin');
const config = {
entry: {
main: [
'./src/js/controller/window.js',
],
},
// Render source-map file for final build
devtool: 'source-map',
// output config
output: {
path: buildPath, // Path of output file
filename: 'window.js', // Name of output file
},
plugins: [
// Define production build to allow React to strip out unnecessary checks
new webpack.DefinePlugin({
'process.env':{
'NODE_ENV': JSON.stringify('production')
}
}),
// Clean build folder
new CleanWebpackPlugin([buildPath]),
// Transfer Files
new CopyWebpackPlugin([
{ from: '_locales', to: '_locales' },
{ from: 'icons', to: 'icons' },
{ from: 'clang-newlib', to: 'clang-newlib'},
// { from: 'js/controller/background.js', to: 'background.js'},
// { from: 'js/model', to: 'model'},
{ from: 'manifest.json', to: 'manifest.json'},
{ from: 'window.html', to: 'window.html'}
], {context: path.resolve(__dirname, 'src')}),
new ConcatPlugin({
uglify: true,
sourceMap: false,
fileName: 'background.js',
filesToConcat: ['./src/js/model/**', './src/js/controller/background.js']
})
],
module: {
rules: [
{
test: /\.js$/,
exclude: /node_modules/,
loader: 'babel-loader',
query: {
cacheDirectory: true,
},
},
],
},
};
module.exports = config;