From 20602bcf233790909d6befb0750a6cbbb0e328d6 Mon Sep 17 00:00:00 2001 From: xdrm-brackets Date: Tue, 28 Nov 2017 13:37:49 +0100 Subject: [PATCH] webpack init (+vue) --- .babelrc | 6 +++ .gitignore | 18 +++++++- package.json | 33 +++++++++++++++ view/{homepage.php => index.php} | 11 +---- view/main.js | 7 +++ view/vue/main.vue | 59 ++++++++++++++++++++++++++ webpack.config.js | 73 ++++++++++++++++++++++++++++++++ 7 files changed, 196 insertions(+), 11 deletions(-) create mode 100644 .babelrc mode change 100644 => 100755 .gitignore create mode 100755 package.json rename view/{homepage.php => index.php} (58%) mode change 100644 => 100755 create mode 100755 view/main.js create mode 100755 view/vue/main.vue create mode 100755 webpack.config.js diff --git a/.babelrc b/.babelrc new file mode 100644 index 0000000..e812394 --- /dev/null +++ b/.babelrc @@ -0,0 +1,6 @@ +{ + "presets": [ + ["env", { "modules": false }], + "stage-3" + ] +} diff --git a/.gitignore b/.gitignore old mode 100644 new mode 100755 index a22d218..e531552 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,16 @@ -/node_modules -/.vscode \ No newline at end of file +.vscode +.DS_Store +node_modules/ +dist/ +npm-debug.log +yarn-error.log +public_html/js/bundle.js +public_html/js/bundle.js* +package-lock.json + +# Editor directories and files +.idea +*.suo +*.ntvs* +*.njsproj +*.sln diff --git a/package.json b/package.json new file mode 100755 index 0000000..03153e4 --- /dev/null +++ b/package.json @@ -0,0 +1,33 @@ +{ + "name": "ndli1718", + "description": "Nuit de l'Info projet team 'Into The While'", + "version": "1.0.0", + "author": "xdrm-brackets ", + "license": "MIT", + "private": true, + "scripts": { + "dev": "cross-env NODE_ENV=development webpack-dev-server --open --hot", + "build": "cross-env NODE_ENV=production webpack --progress --hide-modules" + }, + "dependencies": { + "vue": "^2.4.4" + }, + "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", + "file-loader": "^1.1.4", + "vue-loader": "^13.0.5", + "vue-template-compiler": "^2.4.4", + "webpack": "^3.6.0", + "webpack-dev-server": "^2.9.1" + } +} diff --git a/view/homepage.php b/view/index.php old mode 100644 new mode 100755 similarity index 58% rename from view/homepage.php rename to view/index.php index 3b1e7e2..3864c6c --- a/view/homepage.php +++ b/view/index.php @@ -21,18 +21,11 @@ -
+
+ \ No newline at end of file diff --git a/view/main.js b/view/main.js new file mode 100755 index 0000000..fcdf9d1 --- /dev/null +++ b/view/main.js @@ -0,0 +1,7 @@ +import Vue from 'vue' +// import App from './vue/main.vue' + +new Vue({ + el: '#mainview', + render: h => h(require('./vue/main.vue')) +}) diff --git a/view/vue/main.vue b/view/vue/main.vue new file mode 100755 index 0000000..f741ca7 --- /dev/null +++ b/view/vue/main.vue @@ -0,0 +1,59 @@ + + + + + diff --git a/webpack.config.js b/webpack.config.js new file mode 100755 index 0000000..3937faf --- /dev/null +++ b/webpack.config.js @@ -0,0 +1,73 @@ +var path = require('path') +var webpack = require('webpack') + +module.exports = { + entry: './view/main.js', + output: { + path: path.resolve(__dirname, './public_html/js'), + publicPath: '/js/', + filename: 'bundle.js' + }, + module: { + 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]' + } + } + ] + }, + resolve: { + alias: { + 'vue$': 'vue/dist/vue.esm.js' + }, + extensions: ['*', '.js', '.vue', '.json'] + }, + performance: { + hints: false + }, + 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 + }) + ]) +}