提交 86c5f3c6 authored 作者: 王鹏飞's avatar 王鹏飞

升级脚手架

上级 a25d153b
var semver = require('semver')
var requiredVersion = require('../package.json').engines.node
function checkNodeVersion (wanted, id) {
if (!semver.satisfies(process.version, wanted)) {
console.log('\x1b[91m%s\x1B[0m',
'You are using Node ' + process.version + ', but this version of ' + id +
' requires Node ' + wanted + '.\nPlease upgrade your Node version.'
)
process.exit(1)
}
}
checkNodeVersion(requiredVersion, '`node uploadAliyunCDN.js`')
const isDev = process.env.NODE_ENV const isDev = process.env.NODE_ENV
const RegStrs = require('./regExpStr.js')
let config = { let config = {
isDev: isDev, isDev: isDev,
...@@ -21,6 +22,8 @@ let config = { ...@@ -21,6 +22,8 @@ let config = {
webpack: {} webpack: {}
} }
config.RegStrs = RegStrs
let vueClientConfig = {} let vueClientConfig = {}
config.domain = '' config.domain = ''
if (config.isDev === 'development') { if (config.isDev === 'development') {
......
/* 由于正则表达式,不能进行跟 gulpfile 中 去注释 在一起 */
module.exports = {
regExp_static: /('|"|`)[\.|\/]*?static\/(.*?\.(png|jpe?g|gif|svg|ico)(\?.*)?)\1/g
}
const _conf = require('./config')
module.exports = function (source) {
if (_conf.isDev !== 'development') {
return source
.replace(_conf.RegStrs.regExp_static, '$1' + _conf.CDN_BASE + _conf.CDN_DIR + 'static/$2$1')
} else {
return source
}
}
...@@ -22,6 +22,8 @@ const $GLOBAL = { ...@@ -22,6 +22,8 @@ const $GLOBAL = {
EntryStaticPath: path.resolve(__dirname, '../' + 'static'), EntryStaticPath: path.resolve(__dirname, '../' + 'static'),
OutputStaticPath: path.resolve(__dirname, '../' + _conf.DesDir + '/static'), OutputStaticPath: path.resolve(__dirname, '../' + _conf.DesDir + '/static'),
RegStrs: _conf.RegStrs,
webConf: { webConf: {
'isDev': _conf.isDev, 'isDev': _conf.isDev,
'serverPort': process.env.SERVER_PORT || 8000, 'serverPort': process.env.SERVER_PORT || 8000,
...@@ -52,7 +54,8 @@ $GLOBAL.BaseConfig = { ...@@ -52,7 +54,8 @@ $GLOBAL.BaseConfig = {
'@api': path.resolve(__dirname, '../' + $GLOBAL.ResDir + '/api'), '@api': path.resolve(__dirname, '../' + $GLOBAL.ResDir + '/api'),
'@action': path.resolve(__dirname, '../' + $GLOBAL.ResDir + '/action'), '@action': path.resolve(__dirname, '../' + $GLOBAL.ResDir + '/action'),
'@tool': path.resolve(__dirname, '../' + $GLOBAL.ResDir + '/tool') '@tool': path.resolve(__dirname, '../' + $GLOBAL.ResDir + '/tool')
} },
extensions: ['.js', '.json', '.jsx', '.vue']
}, },
module: { module: {
rules: [ rules: [
...@@ -62,6 +65,12 @@ $GLOBAL.BaseConfig = { ...@@ -62,6 +65,12 @@ $GLOBAL.BaseConfig = {
exclude: /node_modules/, exclude: /node_modules/,
enforce: 'pre' enforce: 'pre'
}, },
{
test: /\.(vue|js|jsx)|((sa|sc|c)ss)$/,
loader: './build/stringReplaceLoader.js',
exclude: /node_modules/,
enforce: 'pre'
},
{ {
test: /\.vue$/, test: /\.vue$/,
loader: 'vue-loader' loader: 'vue-loader'
...@@ -71,10 +80,32 @@ $GLOBAL.BaseConfig = { ...@@ -71,10 +80,32 @@ $GLOBAL.BaseConfig = {
exclude: /(node_modules)|(dist)/, exclude: /(node_modules)|(dist)/,
loader: 'babel-loader', loader: 'babel-loader',
options: { options: {
presets: ['env', 'stage-2'], presets: [[
'@babel/preset-env',
{
"targets": {
"browsers": [
"last 2 versions",
"ie >= 11"
],
},
corejs: '3.6.5',
useBuiltIns: 'usage'
}
]],
plugins: [ plugins: [
'transform-vue-jsx', '@babel/plugin-syntax-jsx',
'syntax-dynamic-import' '@babel/plugin-proposal-class-properties',
'@babel/plugin-syntax-dynamic-import',
[
'@babel/plugin-transform-runtime',
{
corejs: 3,
helpers: true,
regenerator: true,
useESModules: false
}
]
] ]
} }
}, },
......
...@@ -9,6 +9,7 @@ const VueLoaderPlugin = require('vue-loader/lib/plugin') ...@@ -9,6 +9,7 @@ const VueLoaderPlugin = require('vue-loader/lib/plugin')
const AutoPrefixer = require('autoprefixer') const AutoPrefixer = require('autoprefixer')
const MiniCssExtractPlugin = require('mini-css-extract-plugin') const MiniCssExtractPlugin = require('mini-css-extract-plugin')
const HtmlWebpackPlugin = require('html-webpack-plugin') const HtmlWebpackPlugin = require('html-webpack-plugin')
const HtmlReplaceWebpackPlugin = require('html-replace-webpack-plugin')
const CopyWebpackPlugin = require('copy-webpack-plugin') const CopyWebpackPlugin = require('copy-webpack-plugin')
const VconsoleWebpackPlugin = require('vconsole-webpack-plugin') const VconsoleWebpackPlugin = require('vconsole-webpack-plugin')
const $GLOBAL = require('./webpack.base.conf') const $GLOBAL = require('./webpack.base.conf')
...@@ -158,6 +159,12 @@ if ($GLOBAL.isDev === 'development') { ...@@ -158,6 +159,12 @@ if ($GLOBAL.isDev === 'development') {
collapseWhitespace: true collapseWhitespace: true
} }
}), }),
new HtmlReplaceWebpackPlugin([
{
pattern: $GLOBAL.RegStrs.regExp_static,
replacement: '$1' + $GLOBAL.webConf.CDN_PATH + 'static/$2$1'
}
]),
new CopyWebpackPlugin([ new CopyWebpackPlugin([
{ {
from: $GLOBAL.EntryStaticPath, from: $GLOBAL.EntryStaticPath,
...@@ -167,11 +174,11 @@ if ($GLOBAL.isDev === 'development') { ...@@ -167,11 +174,11 @@ if ($GLOBAL.isDev === 'development') {
return content return content
} }
} }
]) ]),
// $GLOBAL.isDev === 'test' && new VconsoleWebpackPlugin({ new VconsoleWebpackPlugin({
// filter: [], filter: [],
// enable: $GLOBAL.isEnableToIphoneDebugger enable: $GLOBAL.isEnableToIphoneDebugger
// }) })
], ],
optimization: { optimization: {
runtimeChunk: { runtimeChunk: {
......
This source diff could not be displayed because it is too large. You can view the blob instead.
差异被折叠。
差异被折叠。
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论