From 7f70f1ae35523b1d78e65295ff6893d1d7691413 Mon Sep 17 00:00:00 2001 From: Chen Fengyuan Date: Sat, 23 Jun 2018 20:57:55 +0800 Subject: [PATCH] build: update --- .babelrc | 7 +++--- .browserslistrc | 2 ++ .eslintrc | 6 ++--- .gitattributes | 18 +-------------- .gitignore | 48 +-------------------------------------- postcss.config.js | 14 ++++++++---- webpack.config.js | 57 ++++++++--------------------------------------- 7 files changed, 29 insertions(+), 123 deletions(-) create mode 100644 .browserslistrc diff --git a/.babelrc b/.babelrc index e6ee433..993e9f5 100644 --- a/.babelrc +++ b/.babelrc @@ -1,9 +1,8 @@ { "presets": [ ["env", { - "targets": { - "browsers": ["last 2 versions", "ie >= 9"] - } - }] + "modules": false + }], + "stage-0" ] } diff --git a/.browserslistrc b/.browserslistrc new file mode 100644 index 0000000..22784ed --- /dev/null +++ b/.browserslistrc @@ -0,0 +1,2 @@ +last 2 versions +ie >= 10 diff --git a/.eslintrc b/.eslintrc index 54b9129..ed2c67d 100644 --- a/.eslintrc +++ b/.eslintrc @@ -7,8 +7,8 @@ "html" ], "rules": { - "no-alert": 0, - "no-new": 0, - "no-param-reassign": 0 + "no-alert": "off", + "no-new": "off", + "no-param-reassign": "off" } } diff --git a/.gitattributes b/.gitattributes index 8d1ca42..dfe0770 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,18 +1,2 @@ -# Automatically normalize line endings for all text-based files -# http://git-scm.com/docs/gitattributes#_end_of_line_conversion +# Auto detect text files and perform LF normalization * text=auto - -# For the following file types, normalize line endings to LF on -# checkin and prevent conversion to CRLF when they are checked out -# (this is required in order to prevent newline related issues like, -# for example, after the build script is run) -.* text eol=lf -*.css text eol=lf -*.html text eol=lf -*.js text eol=lf -*.json text eol=lf -*.md text eol=lf -*.sh text eol=lf -*.txt text eol=lf -*.vue text eol=lf -*.xml text eol=lf diff --git a/.gitignore b/.gitignore index a699e92..0fa4810 100644 --- a/.gitignore +++ b/.gitignore @@ -1,48 +1,2 @@ -# Project -node_modules -npm-debug.log *.map - -# Windows image file caches -Thumbs.db -ehthumbs.db - -# Folder config file -Desktop.ini - -# Recycle Bin used on file shares -$RECYCLE.BIN/ - -# Windows Installer files -*.cab -*.msi -*.msm -*.msp - -# Windows shortcuts -*.lnk - -# ========================= -# Operating System Files -# ========================= - -# OSX -# ========================= - -.DS_Store -.AppleDouble -.LSOverride - -# Thumbnails -._* - -# Files that might appear on external disk -.Spotlight-V100 -.Trashes - -# Directories potentially created on remote AFP share -.AppleDB -.AppleDesktop -Network Trash Folder -Temporary Items -.apdisk +node_modules diff --git a/postcss.config.js b/postcss.config.js index 43d7812..7674a6e 100644 --- a/postcss.config.js +++ b/postcss.config.js @@ -1,6 +1,12 @@ module.exports = { - plugins: [ - require('postcss-smart-import')(), - require('postcss-cssnext')(), - ], + plugins: { + 'postcss-import': {}, + 'postcss-preset-env': { + stage: 3, + features: { + 'nesting-rules': true, + }, + }, + cssnano: {}, + }, }; diff --git a/webpack.config.js b/webpack.config.js index 4aabf40..032a127 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -1,15 +1,11 @@ -const webpack = require('webpack'); +const HtmlWebpackPlugin = require('html-webpack-plugin'); +const VueLoaderPlugin = require('vue-loader/lib/plugin'); const path = require('path'); -const ip = require('ip'); -const IS_PRODUCTION = process.env.NODE_ENV === 'production'; - -module.exports = { +module.exports = (env = {}) => ({ entry: './src/index.js', output: { path: path.resolve(__dirname, './dist'), - publicPath: 'dist/', - filename: 'app.js', }, module: { rules: [ @@ -20,7 +16,7 @@ module.exports = { { test: /\.css$/, use: [ - 'style-loader', + 'vue-style-loader', { loader: 'css-loader', options: { @@ -35,48 +31,13 @@ module.exports = { loader: 'babel-loader', exclude: /node_modules/, }, - { - test: /\.(png|jpg|gif|svg|eot|ttf|woff|woff2)$/, - loader: 'file-loader', - options: { - name: '[name].[ext]?[hash]', - }, - }, ], }, plugins: [ - new webpack.DefinePlugin({ - 'process.env': { - NODE_ENV: IS_PRODUCTION ? '"production"' : '"development"', - }, + new VueLoaderPlugin(), + new HtmlWebpackPlugin({ + filename: env.production ? '../index.html' : 'index.html', + template: './src/index.html', }), ], - devServer: { - host: ip.address(), - stats: { - colors: true, - chunks: false, - }, - }, - performance: { - hints: false, - }, - devtool: '#eval-source-map', -}; - -if (IS_PRODUCTION) { - module.exports.devtool = false; - - // http://vue-loader.vuejs.org/en/workflow/production.html - module.exports.plugins = (module.exports.plugins || []).concat([ - new webpack.optimize.UglifyJsPlugin({ - sourceMap: true, - compress: { - warnings: false, - }, - }), - new webpack.LoaderOptionsPlugin({ - minimize: true, - }), - ]); -} +});