From 2aa73856d39de65d1d46c5cc3d23c3095c233afb Mon Sep 17 00:00:00 2001 From: xdrm-brackets Date: Tue, 20 Feb 2018 00:46:04 +0100 Subject: [PATCH] +upd gitignore ignore css (compiled scss) dir & node_modules + added multi-compiler webpack.config.js --- .gitignore | 4 ++- package.json | 40 ++++++++++++++++++++++ webpack.config.js | 86 +++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 129 insertions(+), 1 deletion(-) create mode 100644 package.json create mode 100644 webpack.config.js diff --git a/.gitignore b/.gitignore index 49ce3c1..0c052e3 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,3 @@ -/vendor \ No newline at end of file +/vendor +/public_html/css +/node_modules \ No newline at end of file diff --git a/package.json b/package.json new file mode 100644 index 0000000..03554d9 --- /dev/null +++ b/package.json @@ -0,0 +1,40 @@ +{ + "name": "ptut-vhost", + "description": "PTUT", + "version": "1.0.0", + "author": "xdrm-brackets SeekDaSky ", + "license": "MIT", + "private": true, + "scripts": { + "build:clean": "rm ./public_html/js/bundle/*.js*;exit 0", + "build:bundle": "cross-env NODE_ENV=production webpack --progress --hide-modules", + "build:dev": "cross-env NODE_ENV=development webpack --progress --hide-modules", + "dev": "npm run build:clean; npm run build:dev", + "build": "npm run build:clean; npm run build:bundle", + "scss": "node-sass -r --output-style ./public_html/scss --output ./public_html/css ./public_html/scss" + }, + "dependencies": { + "vue": "^2.5.9" + }, + "browserslist": [ + "> 1%", + "last 2 versions", + "not ie <= 8" + ], + "devDependencies": { + "babel-core": "^6.26.0", + "babel-loader": "^7.1.2", + "babel-preset-env": "^1.6.0", + "babel-preset-stage-3": "^6.24.1", + "cross-env": "^5.0.5", + "css-loader": "^0.28.7", + "extract-text-webpack-plugin": "^3.0.2", + "file-loader": "^1.1.4", + "node-sass": "^4.7.2", + "sass-loader": "^6.0.6", + "vue-loader": "^13.0.5", + "vue-template-compiler": "^2.5.9", + "webpack": "^3.8.1", + "webpack-dev-server": "^2.9.5" + } +} diff --git a/webpack.config.js b/webpack.config.js new file mode 100644 index 0000000..5527c1b --- /dev/null +++ b/webpack.config.js @@ -0,0 +1,86 @@ +var path = require('path') +var webpack = require('webpack') + +const ExtractTextPlugin = require("extract-text-webpack-plugin"); + +const extractSass = new ExtractTextPlugin({ + filename: "[name].css", + disable: process.env.NODE_ENV === "development" +}); + +var mod_common = { + rules: [ + { + test: /\.css$/, + use: [ + 'vue-style-loader', + 'css-loader' + ], + }, { + test: /\.vue$/, + loader: 'vue-loader', + options: { + loaders: {} // other vue-loader options go here + } + }, { + test: /\.js$/, + loader: 'babel-loader', + exclude: /node_modules/ + }, { + test: /\.(png|jpg|gif|svg)$/, + loader: 'file-loader', + options: { name: '[name].[ext]?[hash]' } + } + ] +}; + + + +module.exports = [ { + + name: "home", + entry: './webpack/page/home.js', + output: { + path: path.resolve(__dirname, './public_html/js/bundle'), + publicPath: '/js/bundle/', + filename: 'home@[hash].js' + }, + module: mod_common, + devtool: '#eval-source-map' + +}, { + + name: "login", + entry: './webpack/page/login.js', + output: { + path: path.resolve(__dirname, './public_html/js/bundle'), + publicPath: '/js/bundle/', + filename: 'login@[hash].js' + }, + module: mod_common, + devtool: '#eval-source-map' + +} ] + + + +if (process.env.NODE_ENV === 'production') { + module.exports.devtool = '#source-map' + // http://vue-loader.vuejs.org/en/workflow/production.html + module.exports.plugins = (module.exports.plugins || []).concat([ + new webpack.DefinePlugin({ + 'process.env': { + NODE_ENV: '"production"' + } + }), + new webpack.optimize.UglifyJsPlugin({ + sourceMap: true, + compress: { + warnings: false + } + }), + new webpack.LoaderOptionsPlugin({ + minimize: true + }) + ]) +}