-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.js
76 lines (69 loc) · 2.12 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
var path = require('path')
var webpack = require('webpack')
const HtmlWebpackPlugin = require('html-webpack-plugin');
const CopyWebpackPlugin = require('copy-webpack-plugin');
const PATHS = {
// Files
uiEntry: path.join(__dirname, 'src/ui.tsx'),
bgEntry: path.join(__dirname, 'src/background.ts'),
manifest: path.join(__dirname, 'src/manifest.json'),
//Folders
src: path.join(__dirname, 'src'),
img: path.join(__dirname, 'src/assets'),
build: path.join(__dirname, 'dist'),
nm: path.join(__dirname, 'node_modules')
};
const config = {
entry: {
ui: ['babel-polyfill', PATHS.uiEntry],
background: ['babel-polyfill', PATHS.bgEntry]
},
output: {
filename: "[name].bundle.js",
path: PATHS.build
},
watch: true,
//Enable sourcemaps for debugging webpack's output.
devtool: "source-map",
resolve: {
// Add '.ts' and '.tsx' as resolveable exts.
extensions: [".ts", ".tsx", ".js", "json"]
},
module: {
rules: [
{
// ts -> ES6 -> babel -> ES5
test: /\.(ts|tsx)?$/,
include: PATHS.src,
exclude: PATHS.nm,
loaders: ['babel-loader', 'awesome-typescript-loader']
},
{
enforce: "pre",
test: /\.js$/,
loader: "source-map-loader",
include: PATHS.src
},
{
test: /\.scss$/,
use: [
{ loader: "style-loader" }, // creates style nodes from JS strings
{ loader: "css-loader" }, // translates CSS into CommonJS
{ loader: "sass-loader"}, // compiles Sass to CSS
]
}
]
},
plugins: [
new HtmlWebpackPlugin({
inject: true,
filename: 'index.html',
template: path.join(__dirname, 'src/index.html')
}),
new CopyWebpackPlugin([
{ from: PATHS.manifest },
{ context: PATHS.img, from: 'icon**' }
])
]
}
module.exports = config;