Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

✨ add source-map for example #1791

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion example/index.html
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
<div id="app"></div>
<script src="/dist/bundle.js"></script>
186 changes: 97 additions & 89 deletions example/webpack.config.js
Original file line number Diff line number Diff line change
@@ -1,97 +1,105 @@
const path = require('path')
const HtmlWebpackPlugin = require('html-webpack-plugin')
const VueLoaderPlugin = require('../lib/plugin')

module.exports = {
mode: 'development',
entry: path.resolve(__dirname, './main.js'),
output: {
path: path.resolve(__dirname, 'dist'),
filename: 'bundle.js',
publicPath: '/dist/'
},
devServer: {
stats: "minimal",
contentBase: __dirname
},
module: {
rules: [
// { loader: require.resolve('./debugger') },
{
test: /\.vue$/,
loader: 'vue-loader'
},
// example to apply loader to a custom block without lang="xxx"
// this rule applies to <foo> blocks
{
resourceQuery: /blockType=foo/,
loader: 'babel-loader'
},
// example configuring preprocessor for <template lang="pug">
{
test: /\.pug$/,
oneOf: [
// this applies to <template lang="pug"> in Vue components
{
resourceQuery: /^\?vue/,
use: ['pug-plain-loader']
},
// this applies to pug imports inside JavaScript
{
use: ['raw-loader', 'pug-plain-loader']
}
]
},
// example configuring CSS Modules
{
test: /\.css$/,
oneOf: [
// this applies to <style module>
{
resourceQuery: /module/,
use: [
'vue-style-loader',
{
loader: 'css-loader',
options: {
modules: true,
localIdentName: '[local]_[hash:base64:8]'
module.exports = (env, options) => {
const isDevServer = !!options.$0.match(/webpack-dev-server$/)
return {
mode: 'development',
entry: path.resolve(__dirname, './main.js'),
output: {
path: path.resolve(__dirname, 'dist'),
filename: 'bundle.js',
publicPath: isDevServer ? '/' : './'
},
devServer: {
stats: "minimal",
contentBase: __dirname
},
devtool: 'source-map',
module: {
rules: [
// { loader: require.resolve('./debugger') },
{
test: /\.vue$/,
loader: 'vue-loader'
},
// example to apply loader to a custom block without lang="xxx"
// this rule applies to <foo> blocks
{
resourceQuery: /blockType=foo/,
loader: 'babel-loader'
},
// example configuring preprocessor for <template lang="pug">
{
test: /\.pug$/,
oneOf: [
// this applies to <template lang="pug"> in Vue components
{
resourceQuery: /^\?vue/,
use: ['pug-plain-loader']
},
// this applies to pug imports inside JavaScript
{
use: ['raw-loader', 'pug-plain-loader']
}
]
},
// example configuring CSS Modules
{
test: /\.css$/,
oneOf: [
// this applies to <style module>
{
resourceQuery: /module/,
use: [
'vue-style-loader',
{
loader: 'css-loader',
options: {
modules: true,
localIdentName: '[local]_[hash:base64:8]'
}
}
]
},
// this applies to <style> or <style scoped>
{
use: [
'vue-style-loader',
'css-loader'
]
}
]
},
// exmaple configration for <style lang="scss">
{
test: /\.scss$/,
use: [
'vue-style-loader',
'css-loader',
{
loader: 'sass-loader',
// global data for all components
// this can be read from a scss file
options: {
data: '$color: red;'
}
]
},
// this applies to <style> or <style scoped>
{
use: [
'vue-style-loader',
'css-loader'
]
}
]
},
// exmaple configration for <style lang="scss">
{
test: /\.scss$/,
use: [
'vue-style-loader',
'css-loader',
{
loader: 'sass-loader',
// global data for all components
// this can be read from a scss file
options: {
data: '$color: red;'
}
}
]
]
}
]
},
resolveLoader: {
alias: {
'vue-loader': require.resolve('../lib')
}
},
plugins: [
new HtmlWebpackPlugin({
template: path.resolve(__dirname, 'index.html')
}),
new VueLoaderPlugin()
]
},
resolveLoader: {
alias: {
'vue-loader': require.resolve('../lib')
}
},
plugins: [
new VueLoaderPlugin()
]
}
}
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
"eslint": "^4.19.0",
"eslint-plugin-vue-libs": "^2.1.0",
"file-loader": "^1.1.11",
"html-webpack-plugin": "4.0.0-beta.14",
"html-webpack-plugin": "4.0.0",
"javascript-stringify": "^1.6.0",
"jest": "^23.5.0",
"jsdom": "^11.6.2",
Expand Down
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -5516,10 +5516,10 @@ html-minifier@^3.2.3:
relateurl "0.2.x"
uglify-js "3.4.x"

html-webpack-plugin@4.0.0-beta.14:
version "4.0.0-beta.14"
resolved "https://registry.yarnpkg.com/html-webpack-plugin/-/html-webpack-plugin-4.0.0-beta.14.tgz#1d3dc299a89391c6fb84c6ed94e7ebe53a9261a0"
integrity sha512-gdThA8oCH7PbHMbezNW5LD+hjxXTzwhfi4XFDKKo5Gs0BR1IhVChEZN1ub4YEKQBmOYasdnCGGPEOFggdm9hNA==
html-webpack-plugin@4.0.0:
version "4.0.0"
resolved "https://registry.npm.taobao.org/html-webpack-plugin/download/html-webpack-plugin-4.0.0.tgz#5b3343312554d16ba98d9b1a85348c77bf733b3a"
integrity sha1-WzNDMSVU0WupjZsahTSMd79zOzo=
dependencies:
html-minifier-terser "^5.0.1"
loader-utils "^1.2.3"
Expand Down