mirror of
https://github.com/BookStackApp/BookStack.git
synced 2025-06-06 02:24:33 +08:00
Attempted move to webpack again
This commit is contained in:
10177
package-lock.json
generated
10177
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
44
package.json
44
package.json
@ -1,38 +1,32 @@
|
|||||||
{
|
{
|
||||||
"private": true,
|
"private": true,
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "gulp build",
|
"build": "webpack",
|
||||||
"production": "gulp build --production",
|
"production": "NODE_ENV=production webpack",
|
||||||
"dev": "gulp",
|
"dev": "webpack --watch",
|
||||||
"watch": "gulp",
|
"watch": "gulp",
|
||||||
"permissions": "chown -R $USER:$USER bootstrap/cache storage public/uploads"
|
"permissions": "chown -R $USER:$USER bootstrap/cache storage public/uploads"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"babelify": "^7.3.0",
|
"@babel/core": "^7.0.0-beta.40",
|
||||||
"browserify": "^14.3.0",
|
"@babel/preset-env": "^7.0.0-beta.40",
|
||||||
"envify": "^4.0.0",
|
"babel-loader": "^8.0.0-beta.0",
|
||||||
"gulp": "^3.9.1",
|
"babel-polyfill": "^6.26.0",
|
||||||
"gulp-autoprefixer": "3.1.1",
|
"css-loader": "^0.28.10",
|
||||||
"gulp-clean-css": "^3.0.4",
|
"extract-text-webpack-plugin": "^4.0.0-beta.0",
|
||||||
"gulp-livereload": "^3.8.1",
|
"node-sass": "^4.7.2",
|
||||||
"gulp-minify-css": "1.2.4",
|
"sass-loader": "^6.0.7",
|
||||||
"gulp-plumber": "1.1.0",
|
"style-loader": "^0.20.3",
|
||||||
"gulp-sass": "3.1.0",
|
"uglifyjs-webpack-plugin": "^1.2.3",
|
||||||
"gulp-uglify": "2.1.2",
|
"webpack": "^4.1.1",
|
||||||
"vinyl-buffer": "^1.0.0",
|
"webpack-cli": "^2.0.11",
|
||||||
"vinyl-source-stream": "^1.1.0",
|
"yargs": "^11.0.0"
|
||||||
"watchify": "^3.9.0",
|
|
||||||
"yargs": "^7.1.0"
|
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"axios": "^0.16.1",
|
"axios": "^0.18.0",
|
||||||
"babel-polyfill": "^6.23.0",
|
"clipboard": "^2.0.0",
|
||||||
"babel-preset-es2015": "^6.24.1",
|
|
||||||
"clipboard": "^1.7.1",
|
|
||||||
"codemirror": "^5.26.0",
|
"codemirror": "^5.26.0",
|
||||||
"dropzone": "^4.0.1",
|
"dropzone": "^5.4.0",
|
||||||
"gulp-sourcemaps": "^2.6.1",
|
|
||||||
"gulp-util": "^3.0.8",
|
|
||||||
"markdown-it": "^8.3.1",
|
"markdown-it": "^8.3.1",
|
||||||
"markdown-it-task-lists": "^2.0.0",
|
"markdown-it-task-lists": "^2.0.0",
|
||||||
"moment": "^2.12.0",
|
"moment": "^2.12.0",
|
||||||
|
@ -21,7 +21,6 @@ let componentMapping = {
|
|||||||
window.components = {};
|
window.components = {};
|
||||||
|
|
||||||
let componentNames = Object.keys(componentMapping);
|
let componentNames = Object.keys(componentMapping);
|
||||||
initAll();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initialize components of the given name within the given element.
|
* Initialize components of the given name within the given element.
|
||||||
@ -54,3 +53,5 @@ function initAll(parentElement) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
window.components.init = initAll;
|
window.components.init = initAll;
|
||||||
|
|
||||||
|
export default initAll;
|
@ -1,6 +1,16 @@
|
|||||||
"use strict";
|
import "../sass/styles.scss"
|
||||||
require("babel-polyfill");
|
import "../sass/print-styles.scss"
|
||||||
require('./dom-polyfills');
|
import "../sass/export-styles.scss"
|
||||||
|
|
||||||
|
import "babel-polyfill"
|
||||||
|
import "./dom-polyfills"
|
||||||
|
import "./pages/page-show"
|
||||||
|
import Translations from "./translations"
|
||||||
|
import vues from "./vues/vues"
|
||||||
|
import components from "./components"
|
||||||
|
|
||||||
|
import Vue from "vue"
|
||||||
|
import axios from "axios"
|
||||||
|
|
||||||
// Url retrieval function
|
// Url retrieval function
|
||||||
window.baseUrl = function(path) {
|
window.baseUrl = function(path) {
|
||||||
@ -37,9 +47,6 @@ class EventManager {
|
|||||||
|
|
||||||
window.$events = new EventManager();
|
window.$events = new EventManager();
|
||||||
|
|
||||||
const Vue = require("vue");
|
|
||||||
const axios = require("axios");
|
|
||||||
|
|
||||||
let axiosInstance = axios.create({
|
let axiosInstance = axios.create({
|
||||||
headers: {
|
headers: {
|
||||||
'X-CSRF-TOKEN': document.querySelector('meta[name=token]').getAttribute('content'),
|
'X-CSRF-TOKEN': document.querySelector('meta[name=token]').getAttribute('content'),
|
||||||
@ -60,14 +67,13 @@ Vue.prototype.$events = window.$events;
|
|||||||
|
|
||||||
// Translation setup
|
// Translation setup
|
||||||
// Creates a global function with name 'trans' to be used in the same way as Laravel's translation system
|
// Creates a global function with name 'trans' to be used in the same way as Laravel's translation system
|
||||||
const Translations = require("./translations");
|
|
||||||
let translator = new Translations(window.translations);
|
let translator = new Translations(window.translations);
|
||||||
window.trans = translator.get.bind(translator);
|
window.trans = translator.get.bind(translator);
|
||||||
window.trans_choice = translator.getPlural.bind(translator);
|
window.trans_choice = translator.getPlural.bind(translator);
|
||||||
|
|
||||||
|
// Load vues and components
|
||||||
require("./vues/vues");
|
vues();
|
||||||
require("./components");
|
components();
|
||||||
|
|
||||||
|
|
||||||
//Global jQuery Config & Extensions
|
//Global jQuery Config & Extensions
|
||||||
@ -119,12 +125,11 @@ jQuery.expr[":"].contains = $.expr.createPseudo(function (arg) {
|
|||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
|
console.log('test');
|
||||||
|
|
||||||
// Detect IE for css
|
// Detect IE for css
|
||||||
if(navigator.userAgent.indexOf('MSIE')!==-1
|
if(navigator.userAgent.indexOf('MSIE')!==-1
|
||||||
|| navigator.appVersion.indexOf('Trident/') > 0
|
|| navigator.appVersion.indexOf('Trident/') > 0
|
||||||
|| navigator.userAgent.indexOf('Safari') !== -1){
|
|| navigator.userAgent.indexOf('Safari') !== -1){
|
||||||
document.body.classList.add('flexbox-support');
|
document.body.classList.add('flexbox-support');
|
||||||
}
|
}
|
||||||
|
|
||||||
// Page specific items
|
|
||||||
require("./pages/page-show");
|
|
@ -16,10 +16,17 @@ let vueMapping = {
|
|||||||
|
|
||||||
window.vues = {};
|
window.vues = {};
|
||||||
|
|
||||||
let ids = Object.keys(vueMapping);
|
function load() {
|
||||||
for (let i = 0, len = ids.length; i < len; i++) {
|
let ids = Object.keys(vueMapping);
|
||||||
if (!exists(ids[i])) continue;
|
for (let i = 0, len = ids.length; i < len; i++) {
|
||||||
let config = vueMapping[ids[i]];
|
if (!exists(ids[i])) continue;
|
||||||
config.el = '#' + ids[i];
|
let config = vueMapping[ids[i]];
|
||||||
window.vues[ids[i]] = new Vue(config);
|
config.el = '#' + ids[i];
|
||||||
|
window.vues[ids[i]] = new Vue(config);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export default load;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -82,7 +82,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@yield('bottom')
|
@yield('bottom')
|
||||||
<script src="{{ versioned_asset('js/common.js') }}"></script>
|
<script src="{{ versioned_asset('dist/bundle.js') }}"></script>
|
||||||
@yield('scripts')
|
@yield('scripts')
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
64
webpack.config.js
Normal file
64
webpack.config.js
Normal file
@ -0,0 +1,64 @@
|
|||||||
|
const path = require('path');
|
||||||
|
const dev = process.env.NODE_ENV !== 'production';
|
||||||
|
|
||||||
|
const UglifyJsPlugin = require('uglifyjs-webpack-plugin');
|
||||||
|
const ExtractTextPlugin = require("extract-text-webpack-plugin");
|
||||||
|
|
||||||
|
const extractSass = new ExtractTextPlugin({
|
||||||
|
filename: "[name].css"
|
||||||
|
// disable: process.env.NODE_ENV === "development"
|
||||||
|
});
|
||||||
|
|
||||||
|
const config = {
|
||||||
|
entry: {
|
||||||
|
app: './resources/assets/js/index.js',
|
||||||
|
styles: './resources/assets/sass/styles.scss',
|
||||||
|
"export-styles": './resources/assets/sass/export-styles.scss',
|
||||||
|
"print-styles": './resources/assets/sass/print-styles.scss',
|
||||||
|
},
|
||||||
|
output: {
|
||||||
|
filename: '[name].js',
|
||||||
|
path: path.resolve(__dirname, 'public/dist')
|
||||||
|
},
|
||||||
|
module: {
|
||||||
|
rules: [
|
||||||
|
{
|
||||||
|
test: /\.js$/,
|
||||||
|
exclude: /(node_modules)/,
|
||||||
|
use: {
|
||||||
|
loader: 'babel-loader',
|
||||||
|
options: {
|
||||||
|
presets: ['@babel/preset-env']
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
test: /\.scss$/,
|
||||||
|
use: extractSass.extract({
|
||||||
|
use: [{
|
||||||
|
loader: "css-loader", options: {
|
||||||
|
sourceMap: dev
|
||||||
|
}
|
||||||
|
}, {
|
||||||
|
loader: "sass-loader", options: {
|
||||||
|
sourceMap: dev
|
||||||
|
}
|
||||||
|
}],
|
||||||
|
// use style-loader in development
|
||||||
|
fallback: "style-loader"
|
||||||
|
})
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
plugins: [extractSass]
|
||||||
|
};
|
||||||
|
|
||||||
|
if (dev) {
|
||||||
|
config['devtool'] = 'inline-source-map';
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!dev) {
|
||||||
|
config.plugins.push(new UglifyJsPlugin());
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = config;
|
Reference in New Issue
Block a user