forked from luiscrjunior/sei-trello
-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
121 lines (107 loc) · 3.54 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
116
117
118
119
120
121
const webpack = require('webpack');
const path = require('path');
const ExtractTextPlugin = require('extract-text-webpack-plugin');
const CleanWebpackPlugin = require('clean-webpack-plugin');
const CopyWebpackPlugin = require('copy-webpack-plugin');
/* este diretório é onde será gerada automaticamente toda estrutura da extensão */
const outputPath = path.resolve(__dirname, 'dist/expanded');
module.exports = {
mode: 'development',
entry: {
/* importante para compatibilidade com as promises */
'vendor/js/babel-polyfill.js': 'babel-polyfill',
/* entry points da app */
'js/process_list.js': './src/js/entries/process_list',
'js/process_content.js': './src/js/entries/process_content',
/* outros scripts */
'js/common.js': './src/js/common.js',
'js/background.js': './src/js/background.js',
'js/options.js': './src/js/options.js',
/* página de estilos */
'css/common.css': './src/css/common.scss',
'css/process_list.css': './src/css/process_list.scss',
'css/process_content.css': './src/css/process_content.scss',
},
output: {
path: outputPath,
filename: '[name]',
},
resolve: {
alias: {
'model': path.resolve(__dirname, 'src/js/model'),
'view': path.resolve(__dirname, 'src/js/view'),
'controller': path.resolve(__dirname, 'src/js/controller'),
'api': path.resolve(__dirname, 'src/js/api'),
'actions': path.resolve(__dirname, 'src/js/actions'),
'utils': path.resolve(__dirname, 'src/js/utils'),
},
},
module: {
rules: [
/* estilos neste path serão exportados para um .css */
{
test: /\.scss$/,
include: [
path.resolve(__dirname, 'src/css'),
],
use: ExtractTextPlugin.extract({
fallback: 'style-loader',
use: ['css-loader', 'postcss-loader', 'sass-loader'],
}),
},
/* estilos dos componentes não serão exportados para arquivo */
{
test: /\.scss$/,
include: [
path.resolve(__dirname, 'src/js'),
],
use: ['style-loader', 'css-loader?modules&importLoaders=1', 'postcss-loader', 'sass-loader'],
},
/* estilos dos componentes importados do node_modules */
{
test: /\.(scss|css)$/,
include: [
path.resolve(__dirname, 'node_modules'),
],
use: ['style-loader', 'css-loader?importLoaders=1', 'sass-loader'],
},
/* transforma os js */
{
test: /\.js$/,
exclude: /(node_modules)/,
use: {
loader: 'babel-loader',
options: {
presets: ['@babel/preset-env', '@babel/preset-react'],
plugins: ['transform-object-rest-spread'],
},
},
},
/* carrega as imagens em DataURL*/
{
test: /\.(png|jpg|gif|svg)$/,
use: [
{
loader: 'url-loader',
options: { limit: 8192 },
},
],
},
],
},
plugins: [
new CleanWebpackPlugin(outputPath),
new CopyWebpackPlugin([
{ from: 'src/manifest.json', to: outputPath + '/' },
{ from: 'src/icons', to: outputPath + '/icons' },
{ from: 'src/html', to: outputPath + '/html' },
{ from: 'src/vendor', to: outputPath + '/vendor' },
]),
new ExtractTextPlugin('[name]'),
new webpack.DefinePlugin({
DEVELOPMENT: JSON.stringify(process.env.NODE_ENV === 'development'),
PRODUCTION: JSON.stringify(process.env.NODE_ENV === 'production'),
'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV),
}),
],
};