-
Notifications
You must be signed in to change notification settings - Fork 9
/
webpack.config.js
92 lines (88 loc) · 2.07 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
const path = require('path')
const CopyPlugin = require('copy-webpack-plugin')
const { CleanWebpackPlugin } = require('clean-webpack-plugin')
const MiniCssExtractPlugin = require('mini-css-extract-plugin')
const HtmlWebpackPlugin = require('html-webpack-plugin')
const srcPath = path.resolve(process.cwd(), 'src') + path.sep;
const buildPath = path.resolve(process.cwd(), 'build') + path.sep;
module.exports =
{
mode: 'production',
entry: {
'mwdk-splash.js': [
path.join(srcPath, 'mwdk.splash.js')
],
'mwdk-package.js': [
path.join(srcPath, 'mwdk.package.js'),
],
'mwdk-helpers.js': [
path.join(srcPath, 'mwdk.helpers.js')
]
},
// write files to the outputPath (default = ./build) using the object keys from 'entry' above
output: {
path: buildPath,
filename: '[name]',
publicPath: buildPath,
clean: true
},
module: {
rules: [
{
test: /\.css$/i,
use: [
{
loader: MiniCssExtractPlugin.loader,
},
{
loader: "css-loader",
options: {
url: false,
},
},
],
},
{
test: /\.scss$/i,
use: [
// Creates `style` nodes from JS strings
"style-loader",
// Translates CSS into CommonJS
"css-loader",
// Compiles Sass to CSS
"sass-loader",
],
},
{
test: /\.js$/i,
use: [
{
loader: "babel-loader"
}
],
},
],
},
plugins: [
new MiniCssExtractPlugin({
filename: '[name].css'
}),
// new CleanWebpackPlugin(),
new CopyPlugin({
patterns: [
{
from: path.resolve(__dirname, 'assets', 'img'),
to: path.resolve(buildPath, 'img'),
toType: 'dir'
}
],
}),
new HtmlWebpackPlugin()
],
// this used to be here to enable a single webpack to build
// both MSCA and this project at the same time
// I think it's less usefull now that npm packages come with pre-built assets
// I'm leaving it here for now...
// It'd probably be safe to delete this some time after v2.1.0 lands
// require('materia-server-client-assets/webpack.config.js')
}