Skip to content

Commit 4765acd

Browse files
committed
update webpack4.x
1 parent 296fca1 commit 4765acd

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+189
-1892
lines changed

meta.js

Lines changed: 0 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -43,39 +43,8 @@ module.exports = {
4343
ie: {
4444
type: 'confirm',
4545
message: ' Support IE or older browser?'
46-
},
47-
vuex: {
48-
type: 'confirm',
49-
message: 'Use vuex?'
50-
},
51-
autoInstall: {
52-
type: 'list',
53-
message:
54-
'Should we run `npm install` for you after the project has been created? (recommended)',
55-
choices: [
56-
{
57-
name: 'Yes, use NPM',
58-
value: 'npm',
59-
short: 'npm',
60-
},
61-
{
62-
name: 'Yes, use Yarn',
63-
value: 'yarn',
64-
short: 'yarn',
65-
},
66-
{
67-
name: 'No, I will handle that myself',
68-
value: false,
69-
short: 'no',
70-
},
71-
]
7246
}
7347
},
74-
filters: {
75-
'src/components/views/todo/**/*': 'vuex',
76-
'src/store/**/*': 'vuex',
77-
'typings/interface/state.d.ts': 'vuex'
78-
},
7948
complete(data, { chalk }) {
8049
const green = chalk.green
8150

template/.vscode/settings.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
{
2-
"prettier.stylelintIntegration": true
2+
"prettier.stylelintIntegration": true,
3+
"editor.formatOnSave": true
34
}

template/build/build.js

Lines changed: 28 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ const path = require('path')
88
const chalk = require('chalk')
99
const webpack = require('webpack')
1010
const inquirer = require('inquirer')
11-
const envList = ['doc', 'dev', 'sit', 'deploy']
11+
const envList = ['doc', 'dev', 'sit', 'uat', 'deploy']
1212

1313
async function build() {
1414
if (!process.env.ENV) {
@@ -24,33 +24,37 @@ async function build() {
2424
const config = require('./config')
2525
const utils = require('./utils')
2626

27-
rm(
28-
path.join(config.build.assetsRoot, config.build.assetsSubDirectory),
29-
async err => {
30-
if (err) throw err
31-
try {
32-
let loader = utils.loading('building for dll...')
33-
const dllWebpackConfig = require('./webpack.dll.conf')
34-
await utils.runWebpack(dllWebpackConfig)
35-
loader.stop()
27+
return new Promise((resolve, reject) => {
28+
rm(
29+
path.join(config.build.assetsRoot, config.build.assetsSubDirectory),
30+
async err => {
31+
if (err) return reject(err)
32+
try {
33+
let loader = utils.loading('building for dll...')
34+
const dllWebpackConfig = require('./webpack.dll.conf')
35+
await utils.runWebpack(dllWebpackConfig)
36+
loader.stop()
3637

37-
loader = utils.loading('building for production... ')
38-
const webpackConfig = require('./webpack.prod.conf')
39-
await utils.runWebpack(webpackConfig)
40-
loader.stop()
38+
loader = utils.loading('building for production... ')
39+
const webpackConfig = require('./webpack.prod.conf')
40+
await utils.runWebpack(webpackConfig)
41+
loader.stop()
4142

42-
console.log(chalk.cyan(' Build complete.\n'))
43-
console.log(
44-
chalk.yellow(
45-
' Tip: built files are meant to be served over an HTTP server.\n' +
46-
" Opening index.html over file:// won't work.\n"
43+
console.log(chalk.cyan(' Build complete.\n'))
44+
console.log(
45+
chalk.yellow(
46+
' Tip: built files are meant to be served over an HTTP server.\n' +
47+
" Opening index.html over file:// won't work.\n"
48+
)
4749
)
48-
)
49-
} catch (error) {
50-
console.log(chalk.red(error))
50+
resolve()
51+
} catch (error) {
52+
console.log(chalk.red(error))
53+
reject(error)
54+
}
5155
}
52-
}
53-
)
56+
)
57+
})
5458
}
5559

5660
if (!module.parent) {

template/build/config/index.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,8 @@ module.exports = {
4848
// Paths
4949
assetsRoot: path.resolve(__dirname, `../../dist/${env}`),
5050
assetsSubDirectory: 'static',
51-
assetsPublicPath: env === 'doc' ? '' : '/',
51+
assetsPublicPath:
52+
env === 'doc' ? '' : 'https://mmf-wx-ali.meimeifa.com/lite-h5/',
5253

5354
/**
5455
* Source Maps

template/build/tpl/index.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33

44
<head>
55
<meta charset="utf-8">
6-
<title>{{ name }}</title>
6+
<title>Vue TypeScript</title>
7+
<meta http-equiv="X-UA-Compatible" content="ie=edge,chrome=1">
78
</head>
89

910
<body>

template/build/utils.js

Lines changed: 0 additions & 97 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,8 @@ require('shelljs/global')
22

33
const path = require('path')
44
const config = require('./config')
5-
const cheerio = require('cheerio')
65
const ora = require('ora')
76
let webpack = require('webpack')
8-
const ExtractTextPlugin = require('extract-text-webpack-plugin')
97
const env = process.env.ENV || 'dev'
108
const packageConfig = require('../package.json')
119

@@ -21,84 +19,6 @@ exports.assetsPath = function(_path) {
2119
return path.posix.join(assetsSubDirectory, _path)
2220
}
2321

24-
exports.cssLoaders = function(options) {
25-
options = options || {}
26-
27-
let cssLoader = {
28-
loader: 'css-loader',
29-
options: {
30-
sourceMap: options.sourceMap
31-
}
32-
}
33-
34-
const postcssLoader = {
35-
loader: 'postcss-loader',
36-
options: {
37-
sourceMap: options.sourceMap
38-
}
39-
}
40-
41-
// generate loader string to be used with extract text plugin
42-
// generate loader string to be used with extract text plugin
43-
function generateLoaders(loader, loaderOptions) {
44-
const loaders = options.usePostCSS
45-
? [cssLoader, postcssLoader]
46-
: [cssLoader]
47-
48-
if (loader) {
49-
loaders.push({
50-
loader: loader + '-loader',
51-
options: Object.assign({}, loaderOptions, {
52-
sourceMap: options.sourceMap
53-
})
54-
})
55-
}
56-
57-
// Extract CSS when that option is specified
58-
// (which is the case during production build)
59-
if (options.extract) {
60-
return ExtractTextPlugin.extract({
61-
use: loaders,
62-
fallback: 'vue-style-loader'
63-
})
64-
} else {
65-
return ['vue-style-loader'].concat(loaders)
66-
}
67-
}
68-
69-
// http://vuejs.github.io/vue-loader/en/configurations/extract-css.html
70-
return {
71-
css: generateLoaders(),
72-
postcss: generateLoaders(),
73-
less: generateLoaders('less'),
74-
sass: generateLoaders('sass', { indentedSyntax: true }),
75-
scss: generateLoaders('sass', {
76-
includePaths: [
77-
path.join(__dirname, '../src/style'),
78-
path.join(__dirname, '../node_modules')
79-
]
80-
}),
81-
stylus: generateLoaders('stylus'),
82-
styl: generateLoaders('stylus')
83-
}
84-
}
85-
86-
// Generate loaders for standalone style files (outside of .vue)
87-
exports.styleLoaders = function(options) {
88-
const output = []
89-
const loaders = exports.cssLoaders(options)
90-
91-
for (const extension in loaders) {
92-
const loader = loaders[extension]
93-
output.push({
94-
test: new RegExp('\\.' + extension + '$'),
95-
use: loader
96-
})
97-
}
98-
99-
return output
100-
}
101-
10222
exports.getDllNames = function() {
10323
let map = {}
10424
ls(path.join(assetsRoot, assetsSubDirectory, '**/*.dll.*.js')).forEach(
@@ -116,23 +36,6 @@ exports.getDllNames = function() {
11636
return map
11737
}
11838

119-
// 去掉 html 标签
120-
exports.strip = function(html, tags) {
121-
let $ = cheerio.load(html, { decodeEntities: false })
122-
if (!tags || tags.length === 0) {
123-
return html
124-
}
125-
126-
tags = !Array.isArray(tags) ? [tags] : tags
127-
let len = tags.length
128-
129-
while (len--) {
130-
$(tags[len]).remove()
131-
}
132-
133-
return $('body').html()
134-
}
135-
13639
exports.createNotifierCallback = () => {
13740
const notifier = require('node-notifier')
13841

template/build/vue-loader.conf.js

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,15 @@
11
'use strict'
2-
const utils = require('./utils')
3-
const config = require('./config')
4-
const isProduction = process.env.NODE_ENV === 'production'
5-
const sourceMapEnabled = isProduction
6-
? config.build.productionSourceMap
7-
: config.dev.cssSourceMap
2+
// const utils = require('./utils')
3+
// const config = require('./config')
4+
// const isProduction = process.env.NODE_ENV === 'production'
5+
// const sourceMapEnabled = isProduction
6+
// ? config.build.productionSourceMap
7+
// : config.dev.cssSourceMap
88

99
module.exports = {
10-
loaders: utils.cssLoaders({
11-
sourceMap: sourceMapEnabled,
12-
extract: isProduction
13-
}),
14-
cssSourceMap: sourceMapEnabled,
15-
cacheBusting: config.dev.cacheBusting,
16-
transformToRequire: {
10+
// cssSourceMap: sourceMapEnabled,
11+
// cacheBusting: config.dev.cacheBusting,
12+
transformAssetUrls: {
1713
video: ['src', 'poster'],
1814
source: 'src',
1915
img: 'src',

0 commit comments

Comments
 (0)