Begin to convert script.js to webpack
This commit is contained in:
parent
c0b6e13fa4
commit
8b28e618c0
|
@ -2,4 +2,4 @@ _output
|
||||||
_site
|
_site
|
||||||
.jekyll-metadata
|
.jekyll-metadata
|
||||||
/node_modules
|
/node_modules
|
||||||
/assets/webpack
|
/assets/packed
|
||||||
|
|
|
@ -21,6 +21,7 @@ exclude:
|
||||||
- yarn.lock
|
- yarn.lock
|
||||||
- package-lock.json
|
- package-lock.json
|
||||||
- webpack.config.js
|
- webpack.config.js
|
||||||
|
- node_modules
|
||||||
|
|
||||||
# Markdown
|
# Markdown
|
||||||
|
|
||||||
|
|
|
@ -4,17 +4,20 @@
|
||||||
{% include meta.html %}
|
{% include meta.html %}
|
||||||
{% include polyfills.html %}
|
{% include polyfills.html %}
|
||||||
|
|
||||||
|
<!-- script -->
|
||||||
|
<script src='{{base}}/assets/packed/app.js?t={{ timestamp }}'></script>
|
||||||
|
|
||||||
<!-- 3rd-party libs -->
|
<!-- 3rd-party libs -->
|
||||||
<script src='https://code.jquery.com/jquery-3.1.0.min.js'></script>
|
<!-- <script src='https://code.jquery.com/jquery-3.1.0.min.js'></script> -->
|
||||||
<script src='https://cdn.jsdelivr.net/npm/isotope-layout@3.0.4/dist/isotope.pkgd.min.js'></script>
|
<script src='https://cdn.jsdelivr.net/npm/isotope-layout@3.0.4/dist/isotope.pkgd.min.js'></script>
|
||||||
<script src='https://cdn.jsdelivr.net/npm/prismjs@1.6.0'></script>
|
<!-- <script src='https://cdn.jsdelivr.net/npm/prismjs@1.6.0'></script> -->
|
||||||
{% for lang in page.prism_languages %}
|
{% for lang in page.prism_languages %}
|
||||||
<script src='https://cdn.jsdelivr.net/npm/prismjs@1.6.0/components/prism-{{lang}}.min.js'></script>{% endfor %}
|
<script src='https://cdn.jsdelivr.net/npm/prismjs@1.6.0/components/prism-{{lang}}.min.js'></script>{% endfor %}
|
||||||
<script src='https://cdn.jsdelivr.net/npm/prismjs@1.6.0/plugins/line-highlight/prism-line-highlight.min.js'></script>
|
<script src='https://cdn.jsdelivr.net/npm/prismjs@1.6.0/plugins/line-highlight/prism-line-highlight.min.js'></script>
|
||||||
|
|
||||||
<!-- 3rd-party CSS -->
|
<!-- 3rd-party CSS -->
|
||||||
<link rel='stylesheet' href='https://cdn.jsdelivr.net/npm/sanitize.css@5.0.0/sanitize.css'>
|
<!-- <link rel='stylesheet' href='https://cdn.jsdelivr.net/npm/sanitize.css@5.0.0/sanitize.css'> -->
|
||||||
<link rel='stylesheet' href='https://cdn.jsdelivr.net/npm/prismjs@1.6.0/plugins/line-highlight/prism-line-highlight.css'>
|
<!-- <link rel='stylesheet' href='https://cdn.jsdelivr.net/npm/prismjs@1.6.0/plugins/line-highlight/prism-line-highlight.css'> -->
|
||||||
|
|
||||||
{% comment %}
|
{% comment %}
|
||||||
<!-- No custom fonts -->
|
<!-- No custom fonts -->
|
||||||
|
|
11
_js/app.js
11
_js/app.js
|
@ -1 +1,10 @@
|
||||||
alert('hello')
|
// 3rd party libs
|
||||||
|
window.jQuery = window.$ = require('jquery')
|
||||||
|
window.Prism = require('prismjs')
|
||||||
|
|
||||||
|
// CSS
|
||||||
|
require('sanitize.css')
|
||||||
|
require('prismjs/plugins/line-highlight/prism-line-highlight.css')
|
||||||
|
|
||||||
|
function requireAll (r) { r.keys().forEach(r) }
|
||||||
|
requireAll(require.context('./behaviors/', true, /\.js$/))
|
||||||
|
|
|
@ -0,0 +1,11 @@
|
||||||
|
import $ from 'jquery'
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Behavior: [data-js-no-preview]
|
||||||
|
*/
|
||||||
|
|
||||||
|
$(function () {
|
||||||
|
if (~window.location.search.indexOf('preview=1')) {
|
||||||
|
$('[data-js-no-preview]').remove()
|
||||||
|
}
|
||||||
|
})
|
|
@ -6,17 +6,27 @@ module.exports = {
|
||||||
app: './_js/app.js'
|
app: './_js/app.js'
|
||||||
},
|
},
|
||||||
output: {
|
output: {
|
||||||
path: join(__dirname, '..', 'assets', 'webpack'),
|
path: join(__dirname, '..', 'assets', 'packed'),
|
||||||
filename: '[name].js'
|
filename: '[name].js'
|
||||||
},
|
},
|
||||||
module: {
|
module: {
|
||||||
rules: [
|
rules: [
|
||||||
{ test: /\.js$/,
|
{
|
||||||
|
test: /\.js$/,
|
||||||
exclude: /node_modules/,
|
exclude: /node_modules/,
|
||||||
use: [
|
use: [
|
||||||
{ loader: 'babel-loader' }
|
{ loader: 'babel-loader' }
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
],
|
||||||
|
rules: [
|
||||||
|
{
|
||||||
|
test: /\.css$/,
|
||||||
|
use: [
|
||||||
|
{ loader: 'style-loader' },
|
||||||
|
{ loader: 'css-loader' }
|
||||||
|
]
|
||||||
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
stats: 'minimal'
|
stats: 'minimal'
|
||||||
|
|
|
@ -1,13 +1,3 @@
|
||||||
/*
|
|
||||||
* Behavior: preview=1
|
|
||||||
*/
|
|
||||||
|
|
||||||
$(function () {
|
|
||||||
if (~window.location.search.indexOf('preview=1')) {
|
|
||||||
$('[data-js-no-preview]').remove()
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Behavior: Wrapping
|
* Behavior: Wrapping
|
||||||
*/
|
*/
|
||||||
|
|
11
package.json
11
package.json
|
@ -9,6 +9,8 @@
|
||||||
"babel-core": "6.26.0",
|
"babel-core": "6.26.0",
|
||||||
"babel-loader": "7.1.2",
|
"babel-loader": "7.1.2",
|
||||||
"babel-preset-env": "1.6.0",
|
"babel-preset-env": "1.6.0",
|
||||||
|
"css-loader": "0.28.7",
|
||||||
|
"style-loader": "0.18.2",
|
||||||
"webpack": "3.6.0"
|
"webpack": "3.6.0"
|
||||||
},
|
},
|
||||||
"babel": {
|
"babel": {
|
||||||
|
@ -17,6 +19,13 @@
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "webpack --watch --progress --colors"
|
"dev": "webpack --watch --progress --colors",
|
||||||
|
"prepublish": "webpack"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"isotope-layout": "3.0.4",
|
||||||
|
"jquery": "3.2.1",
|
||||||
|
"prismjs": "1.8.1",
|
||||||
|
"sanitize.css": "5.0.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue