Migrate to webpack

This commit is contained in:
Mikołaj Pich 2020-01-02 18:29:22 +01:00
parent df69383ad2
commit 5743b1ca5d
No known key found for this signature in database
GPG key ID: F62B26E36D4C4BAA
7 changed files with 1554 additions and 148 deletions

1559
package-lock.json generated

File diff suppressed because it is too large Load diff

View file

@ -3,19 +3,22 @@
"version": "0.1.0",
"private": true,
"scripts": {
"serve": "vue-cli-service serve",
"build": "vue-cli-service build",
"serve": "cross-env NODE_ENV=development webpack-dev-server --open --hot",
"build": "cross-env NODE_ENV=production webpack --progress --hide-modules",
"lint": "vue-cli-service lint"
},
"dependencies": {
"@mdi/font": "^4.7.95",
"babel-runtime": "^6.26.0",
"github-markdown-css": "^3.0.1",
"html-webpack-plugin": "^3.2.0",
"moment": "^2.24.0",
"path": "^0.12.7",
"sass": "^1.24.0",
"vue": "^2.6.11",
"vue-analytics": "^5.20.2",
"vue-async-computed": "^3.8.2",
"vue-loader": "^15.8.3",
"vue-markdown": "^2.2.4",
"vue-material-design-icons": "^4.4.0",
"vue-mq": "^1.0.1",
@ -23,18 +26,27 @@
"vue-router": "^3.1.3"
},
"devDependencies": {
"core-js": "^3.6.1",
"@vue/cli-plugin-babel": "^4.1.2",
"@vue/cli-plugin-eslint": "^4.1.2",
"@vue/cli-service": "^4.1.2",
"@vue/eslint-config-airbnb": "^5.0.0",
"babel-eslint": "^10.0.3",
"core-js": "^3.6.1",
"cross-env": "^6.0.3",
"eslint": "^6.8.0",
"eslint-plugin-vue": "^6.1.2",
"html-loader": "^0.5.5",
"lint-staged": "^9.5.0",
"markdown-loader": "^5.1.0",
"node-sass": "^4.13.0",
"prerender-spa-plugin": "^3.4.0",
"raw-loader": "^4.0.0",
"sass-loader": "^8.0.0",
"vue-template-compiler": "^2.6.11"
"style-loader": "^1.1.2",
"vue-template-compiler": "^2.6.11",
"webpack-cli": "^3.3.10",
"vue-style-loader": "^4.1.2",
"webpack": "latest"
},
"gitHooks": {
"pre-commit": "lint-staged"

View file

@ -5,7 +5,6 @@
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width,initial-scale=1.0">
<meta name="description" content="Nieoficjalna aplikacja mobilna do dziennika VULCAN UONET+ dla ucznia i rodzica na urządzenia z systemem Android">
<link rel="icon" href="<%= BASE_URL %>favicon.ico">
<title>Wulkanowy | Aplikacja ucznia i rodzica</title>
</head>
<body>

View file

@ -25,7 +25,7 @@
</template>
<script>
import table from '@/assets/features-table.json';
import table from '../assets/features-table.json';
import HomeFeaturesTableCell from './HomeFeaturesTableCell.vue';
export default {

View file

@ -37,4 +37,7 @@ new Vue({
router.push(redirect);
}
},
mounted() {
document.dispatchEvent(new Event('render-event'));
},
}).$mount('#app');

View file

@ -29,7 +29,7 @@
<script>
import VueMarkdown from 'vue-markdown';
import faqMap from '@/assets/faq-map.json';
import faqMap from '../assets/faq-map.json';
export default {
name: 'faq-view',
@ -62,7 +62,7 @@
},
},
mounted() {
this.importFaqAnswers(require.context('@/assets/faq-answers', true, /\.md$/));
this.importFaqAnswers(require.context('../assets/faq-answers', true, /\.md$/));
this.$watch(
'$route',

113
webpack.config.js Normal file
View file

@ -0,0 +1,113 @@
const path = require('path');
const webpack = require('webpack');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const PrerenderSPAPlugin = require('prerender-spa-plugin');
const Renderer = PrerenderSPAPlugin.PuppeteerRenderer;
const VueLoaderPlugin = require('vue-loader/lib/plugin');
module.exports = {
mode: process.env.NODE_ENV,
entry: './src/main.js',
output: {
path: path.resolve(__dirname, './dist'),
publicPath: '/',
filename: 'build.js',
},
module: {
rules: [
{
test: /\.md$/,
use: [
{
loader: 'raw-loader',
},
{
loader: 'markdown-loader',
},
],
},
{
test: /\.vue$/,
loader: 'vue-loader',
},
{
test: /\.js$/,
loader: 'babel-loader',
exclude: /node_modules/,
},
{
test: /\.(png|jpg|gif|svg|eot|woff|woff2|ttf)$/,
loader: 'file-loader',
options: {
name: '[name].[ext]?[hash]',
},
},
{
test: /\.s?css$/,
use: [
'vue-style-loader',
'css-loader',
'sass-loader',
],
},
],
},
resolve: {
alias: {
vue$: 'vue/dist/vue.esm.js',
},
},
devServer: {
historyApiFallback: true,
noInfo: false,
},
devtool: '#eval-source-map',
plugins: [
new VueLoaderPlugin(),
],
};
if (process.env.NODE_ENV === 'production') {
module.exports.devtool = '#source-map';
module.exports.plugins = (module.exports.plugins || []).concat([
new webpack.DefinePlugin({
'process.env': {
NODE_ENV: '"production"',
},
}),
new HtmlWebpackPlugin({
title: 'PRODUCTION prerender-spa-plugin',
template: 'public/index.html',
filename: path.resolve(__dirname, 'dist/index.html'),
favicon: 'public/favicon.ico',
}),
new PrerenderSPAPlugin({
staticDir: path.join(__dirname, 'dist'),
routes: ['/polityka-prywatnosci', '/czesto-zadawane-pytania'],
renderer: new Renderer({
inject: {
foo: 'bar',
},
headless: false,
renderAfterDocumentEvent: 'render-event',
}),
}),
]);
} else {
// NODE_ENV === 'development'
module.exports.plugins = (module.exports.plugins || []).concat([
new webpack.DefinePlugin({
'process.env': {
NODE_ENV: '"development"',
},
}),
new HtmlWebpackPlugin({
title: 'DEVELOPMENT prerender-spa-plugin',
template: 'public/index.html',
filename: 'index.html',
favicon: 'public/favicon.ico',
}),
]);
}