-
Notifications
You must be signed in to change notification settings - Fork 116
/
webpack.config.js
127 lines (114 loc) · 4.11 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
122
123
124
125
const path = require('path');
const UglifyJsPlugin = require('uglifyjs-webpack-plugin')
const shell = require('shelljs');
const outputPath = path.resolve( __dirname, 'views/assets/js')
const plugins = [];
const isProduction = (process.env.NODE_ENV == 'production');
const ExtractTextPlugin = require('extract-text-webpack-plugin');
const OptimizeCSSPlugin = require('optimize-css-assets-webpack-plugin');
const DependencyExtractionWebpackPlugin = require( '@wordpress/dependency-extraction-webpack-plugin' );
//Remove all webpack build file
shell.rm('-rf', outputPath)
shell.rm('-rf', path.resolve( __dirname, 'views/assets/vendor/wp-hooks/pm-hooks.js'))
function resolve (dir) {
return path.join(__dirname, './views/assets/src', dir)
}
if (isProduction) {
plugins.push(
new UglifyJsPlugin()
)
}
// extract css into its own file
const extractCss = new ExtractTextPlugin({
filename: 'assets/css/pm-style.css'
});
plugins.push( extractCss );
//const pusher = require('./src/pusher/webpack.config.js');
module.exports =[
{
entry: {
'assets/js/pm': './views/assets/src/start.js',
'assets/js/library': './views/assets/src/helpers/library.js',
'assets/js/pmglobal': './views/assets/src/helpers/pmglobal.js',
'assets/vendor/wp-hooks/pm-hooks': './views/assets/vendor/wp-hooks/wp-hooks.js',
'assets/vendor/vue-fullscreen/vue-fullscreen.min': './views/assets/vendor/vue-fullscreen/vue-fullscreen.js',
},
output: {
path: path.resolve(__dirname, 'views'),
filename: '[name].js',
publicPath: '',
//chunkFilename: 'chunk/[chunkhash].chunk-bundle.js',
//jsonpFunction: 'wedevsPmWebpack',
// hotUpdateFunction: 'wedevsPmWebpacks',
},
resolve: {
extensions: ['.js', '.vue', '.json'],
alias: {
'@components': resolve('components'),
'@directives': resolve('directives'),
'@helpers': resolve('helpers'),
'@router': resolve('router'),
'@store': resolve('store'),
'@src': resolve('')
}
},
module: {
rules: [
// doc url https://vue-loader.vuejs.org/en/options.html#loaders
{
test: /\.vue$/,
loader: 'vue-loader',
options: {
loaders: {
js: 'babel-loader',
}
},
},
{
test: /\.js$/,
loader: 'babel-loader',
include: [
resolve(''),
path.resolve('node_modules/vue-color'),
path.resolve('node_modules/vue-multiselect')
],
query: {
presets:[ "env", "stage-3" , "es2015" ]
}
},
{
test: /\.(png|jpg|gif|svg)$/,
loader: 'file-loader',
exclude: /node_modules/,
options: {
name: '[name].[ext]?[hash]',
outputPath: '../css/images/'
}
},
{
test: /\.less$/,
use: extractCss.extract({
use: [
{
loader: "css-loader"
},
{
loader: "less-loader"
}
]
})
},
{
test: /\.css$/,
loader: "style-loader!css-loader"
},
{
test: /\.(png|woff|woff2|eot|ttf|svg)$/,
use: ['url-loader?limit=100000']
}
]
},
plugins: plugins
},
//pusher
]