This repository has been archived by the owner on Jun 6, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.js
81 lines (74 loc) · 2.03 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
const webpack = require("webpack");
const ExtractTextPlugin = require("extract-text-webpack-plugin");
const Clean = require("clean-webpack-plugin");
const path = require("path");
let definePlugin = new webpack.DefinePlugin({
__DEVELOPMENT__: JSON.stringify(JSON.parse(process.env.WEBPACK_ENV === "development")),
__DEBUG__: JSON.stringify(JSON.parse(process.env.WEBPACK_ENV === "debug")),
__BUILD__: JSON.stringify(JSON.parse(process.env.WEBPACK_ENV === "build")),
__VERSION__: (new Date().getTime().toString())
});
let extractSass = new ExtractTextPlugin("assets/stylesheets/[name].bundle.css");
let website = {
entry: {
index: [
path.resolve(__dirname, "source", "assets", "javascripts", "index.js"),
path.resolve(__dirname, "source", "assets", "stylesheets", "index.scss"),
],
head: [
path.resolve(__dirname, "source", "assets", "javascripts", "head.js"),
]
},
resolve: {
modules: [
path.resolve(__dirname, "source", "assets", "javascripts"),
path.resolve(__dirname, "source", "assets", "stylesheets"),
"node_modules"
]
},
output: {
path: path.join(__dirname, ".tmp", "dist"),
filename: path.join("assets", "javascripts", "[name].bundle.js")
},
module: {
rules: [
{
test: /^(?!node_modules).+\.js/i,
use: [
{
loader: "babel-loader",
options: {
presets: ["env", "es2015", "stage-0"]
}
}
]
},
{
test: /^(?!node_modules).+\.s?css/i,
use: extractSass.extract({
use: [
{
loader: "css-loader",
options: {
sourceMap: true
}
},
{
loader: "sass-loader",
options: {
sourceMap: true
}
}
],
fallback: "style-loader"
})
},
]
},
plugins: [
definePlugin,
new Clean([".tmp"]),
extractSass
]
};
module.exports = website;