Skip to content

Commit 634b948

Browse files
committed
test: Disable uglify
1 parent 9a854ec commit 634b948

File tree

1 file changed

+82
-79
lines changed

1 file changed

+82
-79
lines changed

build/build.js

Lines changed: 82 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
const rollup = require('rollup')
2-
const buble = require('rollup-plugin-buble')
3-
const commonjs = require('rollup-plugin-commonjs')
4-
const nodeResolve = require('rollup-plugin-node-resolve')
5-
const { uglify } = require('rollup-plugin-uglify')
6-
const replace = require('rollup-plugin-replace')
7-
const isProd = process.env.NODE_ENV === 'production'
8-
const version = process.env.VERSION || require('../package.json').version
9-
const chokidar = require('chokidar')
10-
const path = require('path')
1+
const rollup = require('rollup');
2+
const buble = require('rollup-plugin-buble');
3+
const commonjs = require('rollup-plugin-commonjs');
4+
const nodeResolve = require('rollup-plugin-node-resolve');
5+
const { uglify } = require('rollup-plugin-uglify');
6+
const replace = require('rollup-plugin-replace');
7+
const isProd = process.env.NODE_ENV === 'production';
8+
const version = process.env.VERSION || require('../package.json').version;
9+
const chokidar = require('chokidar');
10+
const path = require('path');
1111

1212
/**
1313
* @param {{
@@ -24,90 +24,97 @@ async function build(opts) {
2424
plugins: (opts.plugins || []).concat([
2525
buble({
2626
transforms: {
27-
dangerousForOf: true
28-
}}),
27+
dangerousForOf: true,
28+
},
29+
}),
2930
commonjs(),
3031
nodeResolve(),
3132
replace({
3233
__VERSION__: version,
33-
'process.env.SSR': false
34-
})
34+
'process.env.SSR': false,
35+
}),
3536
]),
3637
onwarn: function (message) {
3738
if (message.code === 'UNRESOLVED_IMPORT') {
3839
throw new Error(
3940
`Could not resolve module ` +
40-
message.source +
41-
`. Try running 'npm install' or using rollup's 'external' option if this is an external dependency. ` +
42-
`Module ${message.source} is imported in ${message.importer}`
43-
)
41+
message.source +
42+
`. Try running 'npm install' or using rollup's 'external' option if this is an external dependency. ` +
43+
`Module ${message.source} is imported in ${message.importer}`
44+
);
4445
}
45-
}
46+
},
4647
})
4748
.then(function (bundle) {
48-
var dest = 'lib/' + (opts.output || opts.input)
49+
var dest = 'lib/' + (opts.output || opts.input);
4950

50-
console.log(dest)
51+
console.log(dest);
5152
return bundle.write({
5253
format: 'iife',
53-
output: opts.globalName ? {name: opts.globalName} : {},
54+
output: opts.globalName ? { name: opts.globalName } : {},
5455
file: dest,
55-
strict: false
56-
})
57-
})
56+
strict: false,
57+
});
58+
});
5859
}
5960

6061
async function buildCore() {
61-
const promises = []
62+
const promises = [];
6263

63-
promises.push(build({
64-
input: 'src/core/index.js',
65-
output: 'docsify.js',
66-
}))
64+
promises.push(
65+
build({
66+
input: 'src/core/index.js',
67+
output: 'docsify.js',
68+
})
69+
);
6770

6871
if (isProd) {
69-
promises.push(build({
70-
input: 'src/core/index.js',
71-
output: 'docsify.min.js',
72-
plugins: [uglify()]
73-
}))
72+
promises.push(
73+
build({
74+
input: 'src/core/index.js',
75+
output: 'docsify.min.js',
76+
// plugins: [uglify()]
77+
})
78+
);
7479
}
7580

76-
await Promise.all(promises)
81+
await Promise.all(promises);
7782
}
7883

7984
async function buildAllPlugin() {
8085
var plugins = [
81-
{name: 'search', input: 'search/index.js'},
82-
{name: 'ga', input: 'ga.js'},
83-
{name: 'gtag', input: 'gtag.js'},
84-
{name: 'matomo', input: 'matomo.js'},
85-
{name: 'emoji', input: 'emoji.js'},
86-
{name: 'external-script', input: 'external-script.js'},
87-
{name: 'front-matter', input: 'front-matter/index.js'},
88-
{name: 'zoom-image', input: 'zoom-image.js'},
89-
{name: 'disqus', input: 'disqus.js'},
90-
{name: 'gitalk', input: 'gitalk.js'}
91-
]
86+
{ name: 'search', input: 'search/index.js' },
87+
{ name: 'ga', input: 'ga.js' },
88+
{ name: 'gtag', input: 'gtag.js' },
89+
{ name: 'matomo', input: 'matomo.js' },
90+
{ name: 'emoji', input: 'emoji.js' },
91+
{ name: 'external-script', input: 'external-script.js' },
92+
{ name: 'front-matter', input: 'front-matter/index.js' },
93+
{ name: 'zoom-image', input: 'zoom-image.js' },
94+
{ name: 'disqus', input: 'disqus.js' },
95+
{ name: 'gitalk', input: 'gitalk.js' },
96+
];
9297

9398
const promises = plugins.map(item => {
9499
return build({
95100
input: 'src/plugins/' + item.input,
96-
output: 'plugins/' + item.name + '.js'
97-
})
98-
})
101+
output: 'plugins/' + item.name + '.js',
102+
});
103+
});
99104

100105
if (isProd) {
101106
plugins.forEach(item => {
102-
promises.push(build({
103-
input: 'src/plugins/' + item.input,
104-
output: 'plugins/' + item.name + '.min.js',
105-
plugins: [uglify()]
106-
}))
107-
})
107+
promises.push(
108+
build({
109+
input: 'src/plugins/' + item.input,
110+
output: 'plugins/' + item.name + '.min.js',
111+
// plugins: [uglify()]
112+
})
113+
);
114+
});
108115
}
109116

110-
await Promise.all(promises)
117+
await Promise.all(promises);
111118
}
112119

113120
async function main() {
@@ -117,41 +124,37 @@ async function main() {
117124
atomic: true,
118125
awaitWriteFinish: {
119126
stabilityThreshold: 1000,
120-
pollInterval: 100
121-
}
127+
pollInterval: 100,
128+
},
122129
})
123130
.on('change', p => {
124-
console.log('[watch] ', p)
125-
const dirs = p.split(path.sep)
131+
console.log('[watch] ', p);
132+
const dirs = p.split(path.sep);
126133
if (dirs[1] === 'core') {
127-
buildCore()
134+
buildCore();
128135
} else if (dirs[2]) {
129-
const name = path.basename(dirs[2], '.js')
136+
const name = path.basename(dirs[2], '.js');
130137
const input = `src/plugins/${name}${
131138
/\.js/.test(dirs[2]) ? '' : '/index'
132-
}.js`
139+
}.js`;
133140

134141
build({
135142
input,
136-
output: 'plugins/' + name + '.js'
137-
})
143+
output: 'plugins/' + name + '.js',
144+
});
138145
}
139146
})
140147
.on('ready', () => {
141-
console.log('[start]')
142-
buildCore()
143-
buildAllPlugin()
144-
})
148+
console.log('[start]');
149+
buildCore();
150+
buildAllPlugin();
151+
});
145152
} else {
146-
await Promise.all([
147-
buildCore(),
148-
buildAllPlugin()
149-
])
153+
await Promise.all([buildCore(), buildAllPlugin()]);
150154
}
151155
}
152156

153-
main().catch((e) => {
154-
console.error(e)
155-
process.exit(1)
156-
})
157-
157+
main().catch(e => {
158+
console.error(e);
159+
process.exit(1);
160+
});

0 commit comments

Comments
 (0)