-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathwebpack.config.js
More file actions
117 lines (114 loc) · 3.28 KB
/
webpack.config.js
File metadata and controls
117 lines (114 loc) · 3.28 KB
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
const path = require('path')
const ExtractTextPlugin = require('extract-text-webpack-plugin')
const HtmlWebpackPlugin = require('html-webpack-plugin')
const HtmlWebpackHarddiskPlugin = require('html-webpack-harddisk-plugin')
const { CleanWebpackPlugin } = require('clean-webpack-plugin')
const { VueLoaderPlugin } = require('vue-loader')
// const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin
const PurgecssPlugin = require('purgecss-webpack-plugin')
let glob = require('glob-all')
const distFolder = path.resolve(__dirname, 'dist')
const jsLoader = 'babel-loader!standard-loader?error=true'
// Custom PurgeCSS extractor for Tailwind that allows special characters in
// class names.
//
// https://github.com/FullHuman/purgecss#extractor
class TailwindExtractor {
static extract (content) {
return content.match(/[A-z0-9-:/]+/g) || []
}
}
module.exports = {
mode: process.env.NODE_ENV === 'prod' ? 'production' : 'development',
resolve: {
alias: {
// use this if you are installing the SDK as dependency
// AE_SDK_MODULES: path.resolve(__dirname, 'node_modules/@aeternity/aepp-sdk/es/')
// use this, if you are running this app from inside the Aepp-SDK repo/folder
AE_SDK_MODULES: '../../../../../es/'
}
},
entry: {
'wallet': './src/index.js'
},
output: {
filename: 'bundle.js?[hash]'
},
node: {
fs: 'empty'
},
devServer: {
contentBase: path.join(__dirname, 'dist'),
port: 9001
},
devtool: process.env.NODE_ENV === 'prod' ? '' : 'eval-source-map',
plugins: [
new HtmlWebpackPlugin({
inject: true,
// chunks: ['wallet'],
title: 'Æpp Example App',
template: './src/index.html',
filename: distFolder + '/index.html',
alwaysWriteToDisk: true
}),
new PurgecssPlugin({
// Specify the locations of any files you want to scan for class names.
paths: glob.sync([
path.join(__dirname, './src/**/*.vue'),
path.join(__dirname, './src/index.html')
]),
extractors: [
{
extractor: TailwindExtractor,
// Specify the file extensions to include when scanning for
// class names.
extensions: ['html', 'js', 'php', 'vue']
}
]
}),
new HtmlWebpackHarddiskPlugin(),
new ExtractTextPlugin('style.css?[hash]'),
new CleanWebpackPlugin(),
new VueLoaderPlugin()
],
module: {
rules: [
{
test: /\.js$/,
// exclude: /node_modules/,
exclude: [/node_modules/],
include: [/node_modules\/@aeternity/, /node_modules\/rlp/],
loader: 'babel-loader'
},
{
test: /\.css$/,
use: ExtractTextPlugin.extract({
use: [
'css-loader',
{
loader: 'postcss-loader',
options: {
config: {
path: 'postcss.config.js'
}
}
}
]
// publicPath: '/web'
})
},
// allows vue compoents in '<template><html><script><style>' syntax
{
test: /\.vue$/,
loader: 'vue-loader',
options: {
loaders: {
js: jsLoader
}
// extractCSS: true
// other vue-loader options go here
}
}
]
}
}