forked from techouse/intl-date-time
-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
109 lines (106 loc) · 3.44 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
const path = require("path"),
outputPath = path.resolve(__dirname, "dist"),
{ CleanWebpackPlugin } = require("clean-webpack-plugin"),
MiniCssExtractPlugin = require("mini-css-extract-plugin"),
Fiber = require("fibers"),
{ VueLoaderPlugin } = require("vue-loader"),
OptimizeCSSAssetsPlugin = require("optimize-css-assets-webpack-plugin"),
TerserPlugin = require("terser-webpack-plugin"),
ManifestPlugin = require("webpack-manifest-plugin"),
env = process.env.NODE_ENV,
isWatch = process.env.npm_lifecycle_event === "watch",
sourceMap = env !== "production",
production = env === "production",
webpack = require("webpack")
const config = {
mode: env,
target: "web",
entry: {
field: [
"./resources/js/field.js",
"./resources/sass/field.scss"
]
},
output: {
path: outputPath,
publicPath: "/nova-vendor/intl-date-time/",
filename: "js/[name].js",
chunkFilename: "js/[name].js",
jsonpFunction: "wpJsonpIntlDateTime"
},
optimization: {},
resolve: {
alias: {
"vue$": "vue/dist/vue.esm.js"
},
extensions: ["*", ".js", ".vue", ".json"],
modules: ["./node_modules",
"./resources/js/components",]
},
stats: {
colors: true
},
devtool: sourceMap ? "cheap-module-eval-source-map" : undefined,
module: {
rules: [
{
test: /\.m?js$/,
loader: "babel-loader"
},
{
test: /\.vue$/,
loader: "vue-loader"
},
{
test: /\.(sa|sc|c)ss$/i,
use: [
{
loader: MiniCssExtractPlugin.loader,
},
{
loader: "css-loader",
options: {
sourceMap,
importLoaders: 2
}
},
{ loader: "postcss-loader", options: { sourceMap } },
"resolve-url-loader",
{
loader: "sass-loader",
options: {
sourceMap,
implementation: require("sass"),
sassOptions: {
fiber: Fiber,
indentWidth: 4,
includePaths: [path.resolve(__dirname, "resources/scss")],
},
}
},]
}
]
},
plugins: [
new webpack.ProgressPlugin(),
new VueLoaderPlugin(),
new CleanWebpackPlugin({ cleanStaleWebpackAssets: !isWatch }),
new MiniCssExtractPlugin({
filename: "css/[name].css",
chunkFilename: "css/[name].css"
}),
new ManifestPlugin({
fileName: "mix-manifest.json"
})
]
}
if (production) {
config.optimization.minimizer = [
new OptimizeCSSAssetsPlugin(),
new TerserPlugin({
cache: true,
parallel: true,
}),
]
}
module.exports = config