-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.prod.config.js
114 lines (109 loc) · 3 KB
/
webpack.prod.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
'use strict';
const path = require('path')
const webpack = require('webpack')
const ExtractTextPlugin = require('extract-text-webpack-plugin')
const autoprefixer = require('autoprefixer')
const ChromeManifestPlugin = require('./plugins/chromemanifest.plugin.js')
const packageJson = require('./package.json')
const configJson = require('./config/production.json')
const TARGET_BROWSER = process.env.TARGET_BROWSER || 'chrome'
let extractStyles = new ExtractTextPlugin('styles/[name].css')
let extractHtml = new ExtractTextPlugin('[name].html')
module.exports = {
context: path.join(__dirname, 'src'),
output: {
path: path.join(__dirname, 'build/prod', TARGET_BROWSER),
filename: '[name].js'
},
entry: {
background: './background/index.js',
newtab: './newtab/index.js'
},
module: {
rules: [
{
test: /\.js$/,
loader: 'babel-loader',
query: {
plugins: ['transform-runtime'],
presets: ['env'],
babelrc: false
},
exclude: /node_modules/
},
{
test: /\.pug$/,
loader: extractHtml.extract({
use: ['html-loader', 'pug-html-loader?pretty&exports=false']
}),
exclude: /node_modules/
},
{ test: /\.json$/, loaders: ['json-loader'], exclude: /node_modules/ },
{
test: /\.scss$/,
loader: extractStyles.extract({
fallback: 'style-loader',
use: [
{ loader: 'css-loader' },
{ loader: 'sass-loader' },
{
loader: 'postcss-loader',
options: {
postcss: [ autoprefixer({ browsers: ['last 2 versions'] }) ]
}
}
]
}),
},
{
test: /\.css$/,
loader: extractStyles.extract({
fallback: 'style-loader',
use: [
{ loader: 'css-loader' },
{
loader: 'postcss-loader',
options: {
postcss: [ autoprefixer({ browsers: ['last 2 versions'] }) ]
}
}
]
})
},
{ test: /\.(png|jpg|svg)$/, loader: 'file-loader?name=images/[name].[ext]&publicPath=/'}
]
},
plugins: [
new webpack.DefinePlugin({
'process.env': {
'NODE_ENV': '"production"'
}
}),
new webpack.optimize.UglifyJsPlugin({
minimize: true,
compress: {
warnings: false
},
screw_ie8: true
}),
new ChromeManifestPlugin({
template: 'manifest.json',
filename: 'manifest.json',
name: packageJson.name,
description: packageJson.description,
version: packageJson.version,
domain: configJson.domain,
browser: TARGET_BROWSER
}),
extractStyles,
extractHtml,
],
resolve: {
alias: {
config: path.join(__dirname, 'config/production'),
browser: path.join(__dirname, 'polyfills', TARGET_BROWSER),
samagri: path.join(__dirname, 'src/samagri')
},
extensions: ['.js', '.json', '.pug']
}
};