Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit099615e

Browse files
committed
webpack
1 parentda98ad8 commit099615e

File tree

7 files changed

+368
-338
lines changed

7 files changed

+368
-338
lines changed

‎build/build.js‎

Lines changed: 24 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -15,27 +15,31 @@ const spinner = ora('building for production...')
1515
spinner.start()
1616

1717
rm(path.join(config.build.assetsRoot,config.build.assetsSubDirectory),err=>{
18-
if(err)throwerr
19-
webpack(webpackConfig,(err,stats)=>{
20-
spinner.stop()
2118
if(err)throwerr
22-
process.stdout.write(stats.toString({
23-
colors:true,
24-
modules:false,
25-
children:false,// If you are using ts-loader, setting this to true will make TypeScript errors show up during build.
26-
chunks:false,
27-
chunkModules:false
28-
})+'\n\n')
19+
webpack(webpackConfig,(err,stats)=>{
20+
spinner.stop()
21+
if(err)throwerr
22+
process.stdout.write(
23+
stats.toString({
24+
colors:true,
25+
modules:false,
26+
children:false,// If you are using ts-loader, setting this to true will make TypeScript errors show up during build.
27+
chunks:false,
28+
chunkModules:false,
29+
})+'\n\n'
30+
)
2931

30-
if(stats.hasErrors()){
31-
console.log(chalk.red(' Build failed with errors.\n'))
32-
process.exit(1)
33-
}
32+
if(stats.hasErrors()){
33+
console.log(chalk.red(' Build failed with errors.\n'))
34+
process.exit(1)
35+
}
3436

35-
console.log(chalk.cyan(' Build complete.\n'))
36-
console.log(chalk.yellow(
37-
' Tip: built files are meant to be served over an HTTP server.\n'+
38-
' Opening index.html over file:// won\'t work.\n'
39-
))
40-
})
37+
console.log(chalk.cyan(' Build complete.\n'))
38+
console.log(
39+
chalk.yellow(
40+
' Tip: built files are meant to be served over an HTTP server.\n'+
41+
" Opening index.html over file:// won't work.\n"
42+
)
43+
)
44+
})
4145
})

‎build/check-versions.js‎

Lines changed: 43 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -4,51 +4,61 @@ const semver = require('semver')
44
constpackageConfig=require('../package.json')
55
constshell=require('shelljs')
66

7-
functionexec(cmd){
8-
returnrequire('child_process').execSync(cmd).toString().trim()
7+
functionexec(cmd){
8+
returnrequire('child_process')
9+
.execSync(cmd)
10+
.toString()
11+
.trim()
912
}
1013

1114
constversionRequirements=[
12-
{
13-
name:'node',
14-
currentVersion:semver.clean(process.version),
15-
versionRequirement:packageConfig.engines.node
16-
}
15+
{
16+
name:'node',
17+
currentVersion:semver.clean(process.version),
18+
versionRequirement:packageConfig.engines.node,
19+
},
1720
]
1821

1922
if(shell.which('npm')){
20-
versionRequirements.push({
21-
name:'npm',
22-
currentVersion:exec('npm --version'),
23-
versionRequirement:packageConfig.engines.npm
24-
})
23+
versionRequirements.push({
24+
name:'npm',
25+
currentVersion:exec('npm --version'),
26+
versionRequirement:packageConfig.engines.npm,
27+
})
2528
}
2629

27-
module.exports=function(){
28-
constwarnings=[]
30+
module.exports=function(){
31+
constwarnings=[]
2932

30-
for(leti=0;i<versionRequirements.length;i++){
31-
constmod=versionRequirements[i]
33+
for(leti=0;i<versionRequirements.length;i++){
34+
constmod=versionRequirements[i]
3235

33-
if(!semver.satisfies(mod.currentVersion,mod.versionRequirement)){
34-
warnings.push(mod.name+': '+
35-
chalk.red(mod.currentVersion)+' should be '+
36-
chalk.green(mod.versionRequirement)
37-
)
36+
if(!semver.satisfies(mod.currentVersion,mod.versionRequirement)){
37+
warnings.push(
38+
mod.name+
39+
': '+
40+
chalk.red(mod.currentVersion)+
41+
' should be '+
42+
chalk.green(mod.versionRequirement)
43+
)
44+
}
3845
}
39-
}
4046

41-
if(warnings.length){
42-
console.log('')
43-
console.log(chalk.yellow('To use this template, you must update following to modules:'))
44-
console.log()
47+
if(warnings.length){
48+
console.log('')
49+
console.log(
50+
chalk.yellow(
51+
'To use this template, you must update following to modules:'
52+
)
53+
)
54+
console.log()
4555

46-
for(leti=0;i<warnings.length;i++){
47-
constwarning=warnings[i]
48-
console.log(' '+warning)
49-
}
56+
for(leti=0;i<warnings.length;i++){
57+
constwarning=warnings[i]
58+
console.log(' '+warning)
59+
}
5060

51-
console.log()
52-
process.exit(1)
53-
}
61+
console.log()
62+
process.exit(1)
63+
}
5464
}

‎build/utils.js‎

Lines changed: 77 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -4,98 +4,101 @@ const config = require('../config')
44
constExtractTextPlugin=require('extract-text-webpack-plugin')
55
constpackageConfig=require('../package.json')
66

7-
exports.assetsPath=function(_path){
8-
constassetsSubDirectory=process.env.NODE_ENV==='production'
9-
?config.build.assetsSubDirectory
10-
:config.dev.assetsSubDirectory
7+
exports.assetsPath=function(_path){
8+
constassetsSubDirectory=
9+
process.env.NODE_ENV==='production'
10+
?config.build.assetsSubDirectory
11+
:config.dev.assetsSubDirectory
1112

12-
returnpath.posix.join(assetsSubDirectory,_path)
13+
returnpath.posix.join(assetsSubDirectory,_path)
1314
}
1415

15-
exports.cssLoaders=function(options){
16-
options=options||{}
16+
exports.cssLoaders=function(options){
17+
options=options||{}
1718

18-
constcssLoader={
19-
loader:'css-loader',
20-
options:{
21-
sourceMap:options.sourceMap
19+
constcssLoader={
20+
loader:'css-loader',
21+
options:{
22+
sourceMap:options.sourceMap,
23+
},
2224
}
23-
}
2425

25-
constpostcssLoader={
26-
loader:'postcss-loader',
27-
options:{
28-
sourceMap:options.sourceMap
26+
constpostcssLoader={
27+
loader:'postcss-loader',
28+
options:{
29+
sourceMap:options.sourceMap,
30+
},
2931
}
30-
}
3132

32-
// generate loader string to be used with extract text plugin
33-
functiongenerateLoaders(loader,loaderOptions){
34-
constloaders=options.usePostCSS ?[cssLoader,postcssLoader] :[cssLoader]
35-
36-
if(loader){
37-
loaders.push({
38-
loader:loader+'-loader',
39-
options:Object.assign({},loaderOptions,{
40-
sourceMap:options.sourceMap
41-
})
42-
})
33+
// generate loader string to be used with extract text plugin
34+
functiongenerateLoaders(loader,loaderOptions){
35+
constloaders=options.usePostCSS
36+
?[cssLoader,postcssLoader]
37+
:[cssLoader]
38+
39+
if(loader){
40+
loaders.push({
41+
loader:loader+'-loader',
42+
options:Object.assign({},loaderOptions,{
43+
sourceMap:options.sourceMap,
44+
}),
45+
})
46+
}
47+
48+
// Extract CSS when that option is specified
49+
// (which is the case during production build)
50+
if(options.extract){
51+
returnExtractTextPlugin.extract({
52+
use:loaders,
53+
fallback:'vue-style-loader',
54+
})
55+
}else{
56+
return['vue-style-loader'].concat(loaders)
57+
}
4358
}
4459

45-
//Extract CSS when that option is specified
46-
// (which is the case during production build)
47-
if(options.extract){
48-
returnExtractTextPlugin.extract({
49-
use:loaders,
50-
fallback:'vue-style-loader'
51-
})
52-
}else{
53-
return['vue-style-loader'].concat(loaders)
60+
//https://vue-loader.vuejs.org/en/configurations/extract-css.html
61+
return{
62+
css:generateLoaders(),
63+
postcss:generateLoaders(),
64+
less:generateLoaders('less'),
65+
sass:generateLoaders('sass',{indentedSyntax:true}),
66+
scss:generateLoaders('sass'),
67+
stylus:generateLoaders('stylus'),
68+
styl:generateLoaders('stylus'),
5469
}
55-
}
56-
57-
// https://vue-loader.vuejs.org/en/configurations/extract-css.html
58-
return{
59-
css:generateLoaders(),
60-
postcss:generateLoaders(),
61-
less:generateLoaders('less'),
62-
sass:generateLoaders('sass',{indentedSyntax:true}),
63-
scss:generateLoaders('sass'),
64-
stylus:generateLoaders('stylus'),
65-
styl:generateLoaders('stylus')
66-
}
6770
}
6871

6972
// Generate loaders for standalone style files (outside of .vue)
70-
exports.styleLoaders=function(options){
71-
constoutput=[]
72-
constloaders=exports.cssLoaders(options)
73-
74-
for(constextensioninloaders){
75-
constloader=loaders[extension]
76-
output.push({
77-
test:newRegExp('\\.'+extension+'$'),
78-
use:loader
79-
})
80-
}
81-
82-
returnoutput
73+
exports.styleLoaders=function(options){
74+
constoutput=[]
75+
constloaders=exports.cssLoaders(options)
76+
77+
for(constextensioninloaders){
78+
constloader=loaders[extension]
79+
output.push({
80+
test:newRegExp('\\.'+extension+'$'),
81+
use:loader,
82+
})
83+
}
84+
85+
returnoutput
8386
}
8487

8588
exports.createNotifierCallback=()=>{
86-
constnotifier=require('node-notifier')
89+
constnotifier=require('node-notifier')
8790

88-
return(severity,errors)=>{
89-
if(severity!=='error')return
91+
return(severity,errors)=>{
92+
if(severity!=='error')return
9093

91-
consterror=errors[0]
92-
constfilename=error.file&&error.file.split('!').pop()
94+
consterror=errors[0]
95+
constfilename=error.file&&error.file.split('!').pop()
9396

94-
notifier.notify({
95-
title:packageConfig.name,
96-
message:severity+': '+error.name,
97-
subtitle:filename||'',
98-
icon:path.join(__dirname,'logo.png')
99-
})
100-
}
97+
notifier.notify({
98+
title:packageConfig.name,
99+
message:severity+': '+error.name,
100+
subtitle:filename||'',
101+
icon:path.join(__dirname,'logo.png'),
102+
})
103+
}
101104
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp