-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathfusionfile.js
139 lines (123 loc) · 3.46 KB
/
fusionfile.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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
/**
* Part of fusion project.
*
* @copyright Copyright (C) 2018 Asikart.
* @license MIT
*/
const fusion = require('windwalker-fusion');
const BebelHelper = require('windwalker-fusion/src/helpers/BebelHelper');
// The task `css`
fusion.task('css', function () {
// Watch start
fusion.watch([
'asset/scss/**/*.scss'
]);
// Watch end
// Compile Start
fusion.sass('asset/scss/**/*.scss', 'src/Resources/asset/css/');
// Compile end
});
// The task `js`
fusion.task('js', function () {
// Watch start
fusion.watch([
'asset/src/**/*.js'
]);
// Watch end
// Compile Start
fusion.babel('asset/src/**/*.js', 'src/Resources/asset/js/');
// Compile end
});
fusion.task('ws', function () {
// Watch start
fusion.watch([
'asset/ws/**/*.js'
]);
// Watch end
// Compile Start
fusion.webpack('asset/ws/**/*.js', 'src/Resources/asset/js/webcomponent/', {
webpack: {
// devtool: 'eval-source-map',
mode: process.env.NODE_ENV || 'development',
output: {
filename: '[name].js',
sourceMapFilename: '[name].js.map'
},
stats: {
all: false,
errors: true,
warnings: true,
version: false,
},
module: {
rules: [
{
test: /\.m?js$/,
// Fis LitElement issue, @see https://github.com/Polymer/lit-element/issues/54#issuecomment-439824447
exclude: /node_modules\/(?!(lit-html|@polymer)\/).*/,
use: [{
loader: 'babel-loader',
options: BebelHelper.basicOptions()
}, 'webpack-comment-remover-loader']
}
]
},
plugins: []
}
});
// Compile end
});
// The task `install`
fusion.task('install', function () {
const nodePath = 'node_modules';
const destPath = 'src/Resources/asset/js';
fusion.copy([
'node_modules/@webcomponents/webcomponentsjs/*.js',
'node_modules/@webcomponents/webcomponentsjs/*.map',
'!**/gulpfile.js'
], 'src/Resources/asset/js/webcomponent/');
fusion.copy([
'node_modules/regenerator-runtime/runtime.js'
], 'src/Resources/asset/js/polyfill/');
fusion.js('src/Resources/asset/js/polyfill/runtime.js');
fusion.copy(`${nodePath}/@babel/standalone/*.js`, `${destPath}/polyfill/`);
fusion.copy(`${nodePath}/core-js-bundle/index.js`, `${destPath}/polyfill/core.js`);
fusion.js(`${destPath}/polyfill/core.js`);
fusion.js([
`${nodePath}/@babel/polyfill/dist/*.js`,
`${nodePath}/url-polyfill/url-polyfill*.js`,
`${nodePath}/nodelist-foreach-polyfill/index.js`,
], `${destPath}/polyfill/polyfill.js`);
fusion.copy(`${nodePath}/sweetalert/dist/sweetalert.min.js`, `${destPath}/sweetalert2.min.js`);
});
fusion.default(['css', 'js']);
/*
* APIs
*
* Compile entry:
* fusion.js(source, dest, options = {})
* fusion.babel(source, dest, options = {})
* fusion.ts(source, dest, options = {})
* fusion.typeScript(source, dest, options = {})
* fusion.css(source, dest, options = {})
* fusion.less(source, dest, options = {})
* fusion.sass(source, dest, options = {})
* fusion.copy(source, dest, options = {})
*
* Live Reload:
* fusion.livereload(source, dest, options = {})
* fusion.reload(file)
*
* Gulp proxy:
* fusion.src(source, options)
* fusion.dest(path, options)
* fusion.task(name, deps, fn)
* fusion.watch(glob, opt, fn)
*
* Stream Helper:
* fusion.through(handler) // Same as through2.obj()
*
* Config:
* fusion.disableNotification()
* fusion.enableNotification()
*/