diff --git a/package.json b/package.json index 2a60f5058..5a5e8fc1e 100644 --- a/package.json +++ b/package.json @@ -5,7 +5,7 @@ "main": "dist/mavon-editor.js", "types": "./mavon-editor.d.ts", "scripts": { - "dev": "webpack-dev-server --config webpack/webpack.dev.js", + "dev": "webpack-dev-server --progress --config webpack/webpack.dev.js", "ci-build": "webpack --progress --config webpack/webpack.build.js", "build": "run-s lint test ci-build", "test": "jest", @@ -111,8 +111,8 @@ "postcss-selector-not": "^2.0.0", "raw-loader": "^0.5.1", "style-loader": "^0.17.0", - "stylus": "^0.54.5", - "stylus-loader": "^2.4.0", + "stylus": "^0.54.8", + "stylus-loader": "^2.5.1", "url-loader": "^0.5.8", "vue": "^2.3.4", "vue-jest": "^3.0.7", diff --git a/webpack/webpack.build.js.bak b/webpack/webpack.build.js.bak deleted file mode 100644 index 90810540f..000000000 --- a/webpack/webpack.build.js.bak +++ /dev/null @@ -1,157 +0,0 @@ -/** - * @Author: HuaChao Chen - * @Date: 2017-05-04T23:21:48+08:00 - * @Email: chenhuachaoxyz@gmail.com - * @Filename: webpack.dev.js - * @Last modified by: CHC - * @Last modified time: 2017-05-06T22:00:16+08:00 - * @License: MIT - * @Copyright: 2017 - */ - -var path = require('path'); -var webpack = require('webpack'); -var HtmlWebpackPlugin = require('html-webpack-plugin'); -var ExtractTextPlugin = require('extract-text-webpack-plugin'); -var WebpackMd5Hash = require('webpack-md5-hash'); -// 该插件是对“webpack-md5-hash”的改进:在主文件中获取到各异步模块的hash值,然后将这些hash值与主文件的代码内容一同作为计算hash的参数,这样就能保证主文件的hash值会跟随异步模块的修改而修改。 -// var WebpackSplitHash = require('webpack-split-hash'); -// 压缩css -var OptimizeCssAssetsPlugin = require('optimize-css-assets-webpack-plugin'); - -const extractCSS = new ExtractTextPlugin('css/[name].css'); - -module.exports = { - entry: { - index: path.resolve(__dirname, '../src/index.js') - }, - output: { - path: path.resolve(__dirname, '../dist'), - // publicPath: '/dist/', - filename: 'mavon-editor.js', - library: 'mavon-editor', - libraryTarget: 'umd', - umdNamedDefine: true - }, - externals: { - vue: { - root: 'Vue', - commonjs: 'vue', - commonjs2: 'vue', - amd: 'vue' - } - }, - module: { - rules: [{ - test: /\.vue$/, - loader: 'vue-loader' - }, - { - test: /\.js$/, - loader: 'babel-loader', - exclude: /node_modules/ - }, - { - test: /\.(png|jpg|gif)$/, - loader: 'file-loader', - options: { name: '[name].[ext]?[hash]' } - }, - { test: /\.(woff|ttf|eot|svg)/, loader: 'file-loader?name=font/[name].[ext]&publicPath=../' }, - { - // css代码分割打包 - test: /\.css$/, - // exclude: /node_modules/, - use: extractCSS.extract({ - fallback: 'style-loader', - use: [ - 'css-loader', - { - loader: 'postcss-loader', - options: { - plugins: function() { - return [ - // 允许在子中定义要放在最顶层的样式 - require('postcss-atroot')({}), - // 允许定义样式函数 - require('postcss-mixins')({}), - // import插件 - require('postcss-nested-import')({}), - // 类sass-import插件,但是没法嵌套导入 - // require('postcss-partial-import')({}), - // 嵌套解析插件 - require('postcss-nested')({}), - // 可以通过引用方式引用父/其他样式的属性值 - require('postcss-nesting')({}), - // 允许自定义选择器别名 - require('postcss-custom-selectors')({}), - // 可自定义属性块别名,后面可扩充 - require('postcss-extend')({}), - // 允许类sass的变量定义,for和each语法 - require('postcss-advanced-variables')({}), - // 支持颜色函数color - require('postcss-color-function')({}), - // 支持media的变量定义 - require('postcss-custom-media')({}), - // 支持属性自定义 - require('postcss-custom-properties')({}), - // 支持media的最大最小值定义 可以通过类似@media screen and (width >= 500px) and (width <= 1200px){}来书写 - require('postcss-media-minmax')({}), - // 支持通过@引用本属性块的属性 - require('postcss-property-lookup')({}), - // maches函数,p:matches(:first-child, .special)解析为p:first-child, p.special - require('postcss-selector-matches')({}), - // 支持not解析,p:not(:first-child, .special)解析为p:not(:first-child), p:not(.special) - require('postcss-selector-not')({}) - ]; - } - } - } - ] - }) - },{ - test: /\.styl$/, - loader: 'style-loader!css-loader!stylus-loader' - },{ - test: /\.md$/, - loader: 'raw-loader' - } - ] - }, - resolve: { - alias: { - 'vue$': 'vue/dist/vue.esm.js' - } - }, - devServer: { - historyApiFallback: true, - disableHostCheck: true, - host: '0.0.0.0', - port: '9090' - // hot: true, - // noInfo: true - }, - performance: { - hints: false - }, - plugins: [ - // new webpack.HotModuleReplacementPlugin(), - // new ExtractTextPlugin("css/[name].[contenthash:8].css"), - extractCSS, - // 分离js可能引入的css的chunkhash计算 - new WebpackMd5Hash(), - // 对css文件进行压缩 - new OptimizeCssAssetsPlugin({ - assetNameRegExp: /\.css$/g, - cssProcessor: require('cssnano'), - cssProcessorOptions: { discardComments: { removeAll: true } }, - canPrint: true - }), - new webpack.optimize.UglifyJsPlugin({ - compress: { - warnings: false - } - }) - // new WebpackSplitHash(), - // new ExtractTextPlugin({ filename: 'bundle.css', disable: false, allChunks: true }), - ] -} diff --git a/webpack/webpack.dev.js b/webpack/webpack.dev.js index 286ebddae..6ad5a40ca 100644 --- a/webpack/webpack.dev.js +++ b/webpack/webpack.dev.js @@ -37,9 +37,8 @@ var config = { historyApiFallback: true, disableHostCheck: true, host: 'localhost', - port: '9090' - // hot: true, - // noInfo: true + port: '9090', + stats: 'normal' }, devtool: 'source-map' } diff --git a/webpack/webpack.dev.js.bak b/webpack/webpack.dev.js.bak deleted file mode 100644 index f6eca515e..000000000 --- a/webpack/webpack.dev.js.bak +++ /dev/null @@ -1,156 +0,0 @@ -/** - * @Author: HuaChao Chen - * @Date: 2017-05-04T23:21:48+08:00 - * @Email: chenhuachaoxyz@gmail.com - * @Filename: webpack.dev.js - * @Last modified by: CHC - * @Last modified time: 2017-05-06T22:00:44+08:00 - * @License: MIT - * @Copyright: 2017 - */ - -var path = require('path'); -var webpack = require('webpack'); -var HtmlWebpackPlugin = require('html-webpack-plugin'); -var ExtractTextPlugin = require('extract-text-webpack-plugin'); -var WebpackMd5Hash = require('webpack-md5-hash'); -// 该插件是对“webpack-md5-hash”的改进:在主文件中获取到各异步模块的hash值,然后将这些hash值与主文件的代码内容一同作为计算hash的参数,这样就能保证主文件的hash值会跟随异步模块的修改而修改。 -// var WebpackSplitHash = require('webpack-split-hash'); -// 压缩css -var OptimizeCssAssetsPlugin = require('optimize-css-assets-webpack-plugin'); - -const extractCSS = new ExtractTextPlugin('css/[name].[contenthash:8].css'); - -module.exports = { - entry: { - index: './src/dev/index.js', - vue: ['vue'] - }, - output: { - path: path.resolve(__dirname, './dist'), - // publicPath: '/dist/', - filename: 'js/[name].[chunkhash:8].js', - chunkFilename: 'js/[name].[chunkhash:8].js' - }, - module: { - rules: [{ - test: /\.vue$/, - loader: 'vue-loader' - }, - { - test: /\.js$/, - loader: 'babel-loader', - exclude: /node_modules/ - }, - { - test: /\.(png|jpg|gif)$/, - loader: 'file-loader', - options: { name: '[name].[ext]?[hash]' } - }, - { test: /\.(woff|ttf|eot|svg)/, loader: 'file-loader?name=font/[name].[hash:8].[ext]&publicPath=../' }, - { - // css代码分割打包 - test: /\.css$/, - // exclude: /node_modules/, - use: extractCSS.extract({ - fallback: 'style-loader', - use: [ - 'css-loader', - { - loader: 'postcss-loader', - options: { - plugins: function() { - return [ - // 允许在子中定义要放在最顶层的样式 - require('postcss-atroot')({}), - // 允许定义样式函数 - require('postcss-mixins')({}), - // import插件 - require('postcss-nested-import')({}), - // 类sass-import插件,但是没法嵌套导入 - // require('postcss-partial-import')({}), - // 嵌套解析插件 - require('postcss-nested')({}), - // 可以通过引用方式引用父/其他样式的属性值 - require('postcss-nesting')({}), - // 允许自定义选择器别名 - require('postcss-custom-selectors')({}), - // 可自定义属性块别名,后面可扩充 - require('postcss-extend')({}), - // 允许类sass的变量定义,for和each语法 - require('postcss-advanced-variables')({}), - // 支持颜色函数color - require('postcss-color-function')({}), - // 支持media的变量定义 - require('postcss-custom-media')({}), - // 支持属性自定义 - require('postcss-custom-properties')({}), - // 支持media的最大最小值定义 可以通过类似@media screen and (width >= 500px) and (width <= 1200px){}来书写 - require('postcss-media-minmax')({}), - // 支持通过@引用本属性块的属性 - require('postcss-property-lookup')({}), - // maches函数,p:matches(:first-child, .special)解析为p:first-child, p.special - require('postcss-selector-matches')({}), - // 支持not解析,p:not(:first-child, .special)解析为p:not(:first-child), p:not(.special) - require('postcss-selector-not')({}) - ]; - } - } - } - ] - }) - },{ - test: /\.styl$/, - loader: 'style-loader!css-loader!stylus-loader' - },{ - test: /\.md$/, - loader: 'raw-loader' - } - ] - }, - resolve: { - alias: { - 'vue$': 'vue/dist/vue.esm.js' - } - }, - devServer: { - historyApiFallback: true, - disableHostCheck: true, - host: '0.0.0.0', - port: '9090' - // hot: true, - // noInfo: true - }, - performance: { - hints: false - }, - plugins: [ - new webpack.optimize.CommonsChunkPlugin({ - names: ['vue', 'common'], - filename: 'js/[name].[chunkhash:8].js', - minChunks: Infinity - }), - new HtmlWebpackPlugin({ - filename: 'index.html', - template: 'src/dev/index.html', - inject: true, - hash: false, - chunks: ['common', 'vue', 'index'] - }), - // new webpack.HotModuleReplacementPlugin(), - // new ExtractTextPlugin("css/[name].[contenthash:8].css"), - extractCSS, - // 分离js可能引入的css的chunkhash计算 - new WebpackMd5Hash(), - // 对css文件进行压缩 - new OptimizeCssAssetsPlugin({ - assetNameRegExp: /\.css$/g, - cssProcessor: require('cssnano'), - cssProcessorOptions: { discardComments: { removeAll: true } }, - canPrint: true - }) - // new WebpackSplitHash(), - // new ExtractTextPlugin({ filename: 'bundle.css', disable: false, allChunks: true }), - ], - devtool: '#eval-source-map' -} diff --git a/yarn.lock b/yarn.lock index 516d6e70a..54dd21024 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3597,6 +3597,18 @@ glob@^7.0.3, glob@^7.1.1, glob@^7.1.2, glob@^7.1.3: once "^1.3.0" path-is-absolute "^1.0.0" +glob@^7.1.6: + version "7.2.0" + resolved "https://registry.npmmirror.com/glob/download/glob-7.2.0.tgz#d15535af7732e02e948f4c41628bd910293f6023" + integrity sha1-0VU1r3cy4C6Uj0xBYovZECk/YCM= + dependencies: + fs.realpath "^1.0.0" + inflight "^1.0.4" + inherits "2" + minimatch "^3.0.4" + once "^1.3.0" + path-is-absolute "^1.0.0" + globals@^11.0.1, globals@^11.1.0: version "11.12.0" resolved "https://registry.yarnpkg.com/globals/-/globals-11.12.0.tgz#ab8795338868a0babd8525758018c2a7eb95c42e" @@ -5757,6 +5769,11 @@ mkdirp@^0.5.0, mkdirp@^0.5.1, mkdirp@~0.5.0, mkdirp@~0.5.1, mkdirp@~0.5.x: dependencies: minimist "^1.2.5" +mkdirp@~1.0.4: + version "1.0.4" + resolved "https://registry.npmmirror.com/mkdirp/download/mkdirp-1.0.4.tgz#3eb5ed62622756d79a5f0e2a221dfebad75c2f7e" + integrity sha1-PrXtYmInVteaXw4qIh3+utdcL34= + move-concurrently@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/move-concurrently/-/move-concurrently-1.0.1.tgz#be2c005fda32e0b29af1f05d7c4b33214c701f92" @@ -7765,7 +7782,7 @@ semver@5.3.0: resolved "https://registry.yarnpkg.com/semver/-/semver-5.3.0.tgz#9b2ce5d3de02d17c6012ad326aa6b4d0cf54f94f" integrity sha1-myzl094C0XxgEq0yaqa00M9U+U8= -semver@^6.0.0: +semver@^6.0.0, semver@^6.3.0: version "6.3.0" resolved "https://registry.yarnpkg.com/semver/-/semver-6.3.0.tgz#ee0a64c8af5e8ceea67687b133761e1becbd1d3d" integrity sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw== @@ -8331,7 +8348,7 @@ style-loader@^0.17.0: dependencies: loader-utils "^1.0.2" -stylus-loader@^2.4.0: +stylus-loader@^2.4.0, stylus-loader@^2.5.1: version "2.5.1" resolved "https://registry.yarnpkg.com/stylus-loader/-/stylus-loader-2.5.1.tgz#d5ad8a7e0958adc12b8581e7bb169b9a61d54216" integrity sha1-1a2KfglYrcErhYHnuxabmmHVQhY= @@ -8354,6 +8371,20 @@ stylus@^0.54.5: semver "^6.0.0" source-map "^0.7.3" +stylus@^0.54.8: + version "0.54.8" + resolved "https://registry.nlark.com/stylus/download/stylus-0.54.8.tgz?cache=0&sync_timestamp=1630739860428&other_urls=https%3A%2F%2Fregistry.nlark.com%2Fstylus%2Fdownload%2Fstylus-0.54.8.tgz#3da3e65966bc567a7b044bfe0eece653e099d147" + integrity sha1-PaPmWWa8Vnp7BEv+DuzmU+CZ0Uc= + dependencies: + css-parse "~2.0.0" + debug "~3.1.0" + glob "^7.1.6" + mkdirp "~1.0.4" + safer-buffer "^2.1.2" + sax "~1.2.4" + semver "^6.3.0" + source-map "^0.7.3" + sugarss@^0.2.0: version "0.2.0" resolved "https://registry.yarnpkg.com/sugarss/-/sugarss-0.2.0.tgz#ac34237563327c6ff897b64742bf6aec190ad39e"