mirror of
				https://github.com/KevinMidboe/zoff.git
				synced 2025-10-29 18:00:23 +00:00 
			
		
		
		
	NOT COMPILING. Init vue setup.
This commit is contained in:
		
							
								
								
									
										3
									
								
								config/env/dev.env.js
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										3
									
								
								config/env/dev.env.js
									
									
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,3 @@
 | 
			
		||||
module.exports = {
 | 
			
		||||
  NODE_ENV: "development"
 | 
			
		||||
};
 | 
			
		||||
							
								
								
									
										3
									
								
								config/env/prod.env.js
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										3
									
								
								config/env/prod.env.js
									
									
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,3 @@
 | 
			
		||||
module.exports = {
 | 
			
		||||
  NODE_ENV: "production"
 | 
			
		||||
};
 | 
			
		||||
							
								
								
									
										3
									
								
								config/env/staging.env.js
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										3
									
								
								config/env/staging.env.js
									
									
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,3 @@
 | 
			
		||||
module.exports = {
 | 
			
		||||
  NODE_ENV: "staging"
 | 
			
		||||
};
 | 
			
		||||
							
								
								
									
										15
									
								
								config/helpers.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										15
									
								
								config/helpers.js
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,15 @@
 | 
			
		||||
"use strict";
 | 
			
		||||
 | 
			
		||||
const path = require("path");
 | 
			
		||||
 | 
			
		||||
const _root = path.resolve(__dirname, "..");
 | 
			
		||||
 | 
			
		||||
exports.root = function(args) {
 | 
			
		||||
  args = Array.prototype.slice.call(arguments, 0);
 | 
			
		||||
 | 
			
		||||
  return path.join.apply(path, [_root].concat(args));
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
exports.assetsPath = function(_path) {
 | 
			
		||||
  return path.posix.join("static", _path);
 | 
			
		||||
};
 | 
			
		||||
							
								
								
									
										61
									
								
								config/webpack.config.common.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										61
									
								
								config/webpack.config.common.js
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,61 @@
 | 
			
		||||
"use strict";
 | 
			
		||||
 | 
			
		||||
const VueLoaderPlugin = require("vue-loader/lib/plugin");
 | 
			
		||||
const MiniCSSExtractPlugin = require("mini-css-extract-plugin");
 | 
			
		||||
const helpers = require("./helpers");
 | 
			
		||||
const isDev = process.env.NODE_ENV === "development";
 | 
			
		||||
 | 
			
		||||
const webpackConfig = function(isDev) {
 | 
			
		||||
  return {
 | 
			
		||||
    entry: {
 | 
			
		||||
      main: ["@babel/polyfill", helpers.root("frontend", "main")]
 | 
			
		||||
    },
 | 
			
		||||
    resolve: {
 | 
			
		||||
      extensions: [".js", ".vue"],
 | 
			
		||||
      alias: {
 | 
			
		||||
        vue$: isDev ? "vue/dist/vue.runtime.js" : "vue/dist/vue.runtime.min.js",
 | 
			
		||||
        "@": helpers.root("frontend")
 | 
			
		||||
      }
 | 
			
		||||
    },
 | 
			
		||||
    module: {
 | 
			
		||||
      rules: [
 | 
			
		||||
        {
 | 
			
		||||
          test: /\.vue$/,
 | 
			
		||||
          loader: "vue-loader",
 | 
			
		||||
          include: [helpers.root("frontend")]
 | 
			
		||||
        },
 | 
			
		||||
        {
 | 
			
		||||
          test: /\.js$/,
 | 
			
		||||
          loader: "babel-loader",
 | 
			
		||||
          include: [helpers.root("frontend")]
 | 
			
		||||
        },
 | 
			
		||||
        {
 | 
			
		||||
          test: /\.css$/,
 | 
			
		||||
          use: [
 | 
			
		||||
            isDev ? "vue-style-loader" : MiniCSSExtractPlugin.loader,
 | 
			
		||||
            { loader: "css-loader", options: { sourceMap: isDev } }
 | 
			
		||||
          ]
 | 
			
		||||
        },
 | 
			
		||||
        {
 | 
			
		||||
          test: /\.scss$/,
 | 
			
		||||
          use: [
 | 
			
		||||
            isDev ? "vue-style-loader" : MiniCSSExtractPlugin.loader,
 | 
			
		||||
            { loader: "css-loader", options: { sourceMap: isDev } },
 | 
			
		||||
            { loader: "sass-loader", options: { sourceMap: isDev } }
 | 
			
		||||
          ]
 | 
			
		||||
        },
 | 
			
		||||
        {
 | 
			
		||||
          test: /\.sass$/,
 | 
			
		||||
          use: [
 | 
			
		||||
            isDev ? "vue-style-loader" : MiniCSSExtractPlugin.loader,
 | 
			
		||||
            { loader: "css-loader", options: { sourceMap: isDev } },
 | 
			
		||||
            { loader: "sass-loader", options: { sourceMap: isDev } }
 | 
			
		||||
          ]
 | 
			
		||||
        }
 | 
			
		||||
      ]
 | 
			
		||||
    },
 | 
			
		||||
    plugins: [new VueLoaderPlugin()]
 | 
			
		||||
  };
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
module.exports = webpackConfig;
 | 
			
		||||
							
								
								
									
										45
									
								
								config/webpack.config.dev.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										45
									
								
								config/webpack.config.dev.js
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,45 @@
 | 
			
		||||
"use strict";
 | 
			
		||||
 | 
			
		||||
const webpack = require("webpack");
 | 
			
		||||
const merge = require("webpack-merge");
 | 
			
		||||
const FriendlyErrorsPlugin = require("friendly-errors-webpack-plugin");
 | 
			
		||||
const HtmlPlugin = require("html-webpack-plugin");
 | 
			
		||||
const helpers = require("./helpers");
 | 
			
		||||
const commonConfig = require("./webpack.config.common");
 | 
			
		||||
const environment = require("./env/dev.env");
 | 
			
		||||
 | 
			
		||||
const webpackConfig = merge(commonConfig(true), {
 | 
			
		||||
  mode: "development",
 | 
			
		||||
  devtool: "cheap-module-eval-source-map",
 | 
			
		||||
  output: {
 | 
			
		||||
    path: helpers.root("dist"),
 | 
			
		||||
    publicPath: "/",
 | 
			
		||||
    filename: "js/[name].bundle.js",
 | 
			
		||||
    chunkFilename: "js/[id].chunk.js"
 | 
			
		||||
  },
 | 
			
		||||
  optimization: {
 | 
			
		||||
    runtimeChunk: "single",
 | 
			
		||||
    splitChunks: {
 | 
			
		||||
      chunks: "all"
 | 
			
		||||
    }
 | 
			
		||||
  },
 | 
			
		||||
  plugins: [
 | 
			
		||||
    new webpack.EnvironmentPlugin(environment),
 | 
			
		||||
    new webpack.HotModuleReplacementPlugin(),
 | 
			
		||||
    new FriendlyErrorsPlugin(),
 | 
			
		||||
    new HtmlPlugin({ template: "frontend/index.html", chunksSortMode: "dependency" })
 | 
			
		||||
  ],
 | 
			
		||||
  devServer: {
 | 
			
		||||
    compress: true,
 | 
			
		||||
    historyApiFallback: true,
 | 
			
		||||
    hot: true,
 | 
			
		||||
    open: true,
 | 
			
		||||
    overlay: true,
 | 
			
		||||
    port: 8000,
 | 
			
		||||
    stats: {
 | 
			
		||||
      normal: true
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
});
 | 
			
		||||
 | 
			
		||||
module.exports = webpackConfig;
 | 
			
		||||
							
								
								
									
										55
									
								
								config/webpack.config.prod.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										55
									
								
								config/webpack.config.prod.js
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,55 @@
 | 
			
		||||
"use strict";
 | 
			
		||||
 | 
			
		||||
const webpack = require("webpack");
 | 
			
		||||
const merge = require("webpack-merge");
 | 
			
		||||
const OptimizeCSSAssetsPlugin = require("optimize-css-assets-webpack-plugin");
 | 
			
		||||
const MiniCSSExtractPlugin = require("mini-css-extract-plugin");
 | 
			
		||||
const UglifyJSPlugin = require("uglifyjs-webpack-plugin");
 | 
			
		||||
const CompressionPlugin = require("compression-webpack-plugin");
 | 
			
		||||
const helpers = require("./helpers");
 | 
			
		||||
const commonConfig = require("./webpack.config.common");
 | 
			
		||||
const isProd = process.env.NODE_ENV === "production";
 | 
			
		||||
const environment = isProd
 | 
			
		||||
  ? require("./env/prod.env")
 | 
			
		||||
  : require("./env/staging.env");
 | 
			
		||||
 | 
			
		||||
const webpackConfig = merge(commonConfig(false), {
 | 
			
		||||
  mode: "production",
 | 
			
		||||
  output: {
 | 
			
		||||
    path: helpers.root("dist"),
 | 
			
		||||
    publicPath: "/",
 | 
			
		||||
    filename: "js/[name].bundle.js"
 | 
			
		||||
  },
 | 
			
		||||
  optimization: {
 | 
			
		||||
    minimizer: [
 | 
			
		||||
      new OptimizeCSSAssetsPlugin({
 | 
			
		||||
        cssProcessorPluginOptions: {
 | 
			
		||||
          preset: ["default", { discardComments: { removeAll: true } }]
 | 
			
		||||
        }
 | 
			
		||||
      }),
 | 
			
		||||
      new UglifyJSPlugin({
 | 
			
		||||
        cache: true,
 | 
			
		||||
        parallel: false,
 | 
			
		||||
        sourceMap: !isProd
 | 
			
		||||
      })
 | 
			
		||||
    ]
 | 
			
		||||
  },
 | 
			
		||||
  plugins: [
 | 
			
		||||
    new webpack.EnvironmentPlugin(environment),
 | 
			
		||||
    new MiniCSSExtractPlugin({
 | 
			
		||||
      filename: "css/[name].css"
 | 
			
		||||
    })
 | 
			
		||||
  ]
 | 
			
		||||
});
 | 
			
		||||
 | 
			
		||||
if (!isProd) {
 | 
			
		||||
  webpackConfig.devtool = "source-map";
 | 
			
		||||
 | 
			
		||||
  if (process.env.npm_config_report) {
 | 
			
		||||
    const BundleAnalyzerPlugin = require("webpack-bundle-analyzer")
 | 
			
		||||
      .BundleAnalyzerPlugin;
 | 
			
		||||
    webpackConfig.plugins.push(new BundleAnalyzerPlugin());
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
module.exports = webpackConfig;
 | 
			
		||||
							
								
								
									
										15
									
								
								frontend/App.vue
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										15
									
								
								frontend/App.vue
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,15 @@
 | 
			
		||||
<template>
 | 
			
		||||
  <div>
 | 
			
		||||
    <h1>hello world</h1>
 | 
			
		||||
  </div>
 | 
			
		||||
</template>
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
<script>
 | 
			
		||||
export {
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
</script>
 | 
			
		||||
 | 
			
		||||
<style lang="scss" scoped>
 | 
			
		||||
</style>
 | 
			
		||||
							
								
								
									
										9
									
								
								frontend/index.html
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										9
									
								
								frontend/index.html
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,9 @@
 | 
			
		||||
<!DOCTYPE html>
 | 
			
		||||
<html>
 | 
			
		||||
<head>
 | 
			
		||||
  <title>Zoff</title>
 | 
			
		||||
</head>
 | 
			
		||||
<body>
 | 
			
		||||
  <div id="app"></div>
 | 
			
		||||
</body>
 | 
			
		||||
</html>
 | 
			
		||||
							
								
								
									
										17
									
								
								frontend/main.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										17
									
								
								frontend/main.js
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,17 @@
 | 
			
		||||
import Vue from 'vue'
 | 
			
		||||
import VueRouter from 'vue-router'
 | 
			
		||||
// import router from './routes'
 | 
			
		||||
// import store from './store'
 | 
			
		||||
 | 
			
		||||
import App from './App.vue'
 | 
			
		||||
 | 
			
		||||
Vue.use(VueRouter)
 | 
			
		||||
 | 
			
		||||
new Vue({
 | 
			
		||||
  el: '#app',
 | 
			
		||||
  router,
 | 
			
		||||
  // store,
 | 
			
		||||
  components: { App },
 | 
			
		||||
  // template: '<App />',
 | 
			
		||||
  render: h => h(App)
 | 
			
		||||
})
 | 
			
		||||
							
								
								
									
										9
									
								
								webpack.config.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										9
									
								
								webpack.config.js
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,9 @@
 | 
			
		||||
"use strict";
 | 
			
		||||
 | 
			
		||||
const environment = (process.env.NODE_ENV || "development").trim();
 | 
			
		||||
 | 
			
		||||
if (environment === "development") {
 | 
			
		||||
  module.exports = require("./config/webpack.config.dev");
 | 
			
		||||
} else {
 | 
			
		||||
  module.exports = require("./config/webpack.config.prod");
 | 
			
		||||
}
 | 
			
		||||
		Reference in New Issue
	
	Block a user