This repository has been archived by the owner on Sep 3, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 12
/
webpack.base.config.js
125 lines (123 loc) · 3.2 KB
/
webpack.base.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
116
117
118
119
120
121
122
123
124
125
const path = require('path');
const ExtractTextPlugin = require('extract-text-webpack-plugin');
const CopyWebpackPlugin = require('copy-webpack-plugin');
const autoprefixer = require('autoprefixer');
const styleLoaders = {
fallback: {
loader: require.resolve('style-loader'),
},
use: [
{
loader: require.resolve('css-loader'),
options: {
importLoaders: 1,
minimize: true,
},
},
{
loader: require.resolve('postcss-loader'),
options: {
// Necessary for external CSS imports to work
// https://github.com/facebookincubator/create-react-app/issues/2677
ident: 'postcss',
plugins: () => [
require('postcss-flexbugs-fixes'),
autoprefixer({
flexbox: 'no-2009',
}),
],
},
},'sass-loader'
],
}
module.exports = {
entry: {
background: './src/background/index.ts',
contentscript: './src/contentscript/index.ts',
inpage: './src/inpage/index.ts',
popup: './src/popup/index.tsx',
scryptworker: './src/background/workers/scryptworker.js',
},
output: {
path: path.join(__dirname, 'dist'),
filename: '[name].js',
// @see https://developer.chrome.com/extensions/manifest/web_accessible_resources
publicPath : 'chrome-extension://__MSG_@@extension_id__/',
},
resolve: {
extensions: [
'.ts',
'.tsx',
'.js',
'.jsx',
'.json',
],
},
module: {
rules: [
{
parser: {
amd: false,
}
},
{
test: /\.(ts|tsx)$/,
loaders: require.resolve('tslint-loader'),
enforce: 'pre',
include: path.resolve(__dirname, './src'),
},
{
oneOf: [
{
test: [/\.bmp$/, /\.gif$/, /\.jpe?g$/, /\.png$/],
loader: require.resolve('url-loader'),
options: {
limit: 10000,
name: 'static/[name].[hash:8].[ext]',
},
},
{
test: /\.(ts|tsx)$/,
include: path.resolve(__dirname, './src'),
loader: require.resolve('ts-loader')
},
{
exclude: /node_modules/,
test: /\.s?css$/,
loader: ExtractTextPlugin.extract(
// use css-modules
Object.assign({}, styleLoaders, {
use: (() => {
const copiedUse = styleLoaders.use.slice()
// change css-loader options
const cssLoader = copiedUse[0]
copiedUse[0] = Object.assign({}, cssLoader, {
options: Object.assign({}, cssLoader.options, {
modules: true,
})
})
return copiedUse
})()}
)
),
},
{
loader: require.resolve('file-loader'),
exclude: [/\.js$/, /\.html$/, /\.json$/],
options: {
name: 'static/[name].[hash:8].[ext]',
},
},
],
}
]
},
plugins: [
new ExtractTextPlugin({
filename: '[name].css',
}),
new CopyWebpackPlugin([
{ from: 'static' },
]),
],
}