ОШИБКА в ./src/Loader.vue Ошибка синтаксического анализа модуля: C: \ test \ vuePlugin \ src \ Loader.vue Неожиданный токен (1: 0) Для работы с этим типом файлов вам может потребоваться соответствующий загрузчик. SyntaxError: неожиданный токен (1: 0) в Parser.pp $ 4.raise (C: \ Users \ shubham-sharma2 \ AppData \ Roaming \ npm \ node_modules \ webpack \ node_modules \ acorn \ dist \ acorn.js: 2221: 15) в Parser.pp.unexpected (C: \ Users \ shubham-sharma2 \ AppData \ Roaming \ npm \ node_modules \ webpack \ node_modules \ acorn \ dist \ acorn.js: 603: 10) в Parser.pp $ 3.parseExprAtom (C: \ Users \ shubham-sharma2 \ AppData \ Roaming \ npm \ node_modules \ webpack \ node_modules \ acorn \ dist \ acorn.js: 1822: 12) в Parser.pp $ 3.parseExprSubscripts (C: \ Users \ shubham-sharma2 \ AppData \ Roaming \ npm \ node_modules \ webpack \ node_modules \ acorn \ dist \ acorn.js: 1715: 21) в Parser.pp $ 3.parseMaybeUnary (C: \ Users \ shubham-sharma2 \ AppData \ Roaming \ npm \ node_modules \ webpack \ node_modules \ acorn \ dist \ acorn.js: 1692: 19) в Parser.pp $ 3.parseExprOps (C: \ Users \ shubham-sharma2 \ AppData \ Roaming \ npm \ node_modules \ webpack \ node_modules \ acorn \ dist \ acorn.js: 1637: 21) в Parser.pp $ 3.parseMaybeConditional (C: \ Users \ shubham-sharma2 \ AppData \ Roaming \ npm \ node_modules \ webpack \ node_modules \ acorn \ dist \ acorn.js: 1620: 21) в Parser.pp $ 3.parseMaybeAssign (C: \ Users \ shubham-sharma2 \ AppData \ Roaming \ npm \ node_modules \ webpack \ node_modules \ acorn \ dist \ acorn.js: 1597: 21) в Parser.pp $ 3.parseExpression (C: \ Users \ shubham-sharma2 \ AppData \ Roaming \ npm \ node_modules \ webpack \ node_modules \ acorn \ dist \ acorn.js: 1573: 21) в Parser.pp $ 1.parseStatement (C: \ Users \ shubham-sharma2 \ AppData \ Roaming \ npm \ node_modules \ webpack \ node_modules \ acorn \ dist \ acorn.js: 727: 47) в Parser.pp $ 1.parseTopLevel (C: \ Users \ shubham-sharma2 \ AppData \ Roaming \ npm \ node_modules \ webpack \ node_modules \ acorn \ dist \ acorn.js: 638: 25) в Parser.parse (C: \ Users \ shubham-sharma2 \ AppData \ Roaming \ npm \ node_modules \ webpack \ node_modules \ acorn \ dist \ acorn.js: 516: 17) в Object.parse (C: \ Users \ shubham-sharma2 \ AppData \ Roaming \ npm \ node_modules \ webpack \ node_modules \ acorn \ dist \ acorn.js: 3098: 39) в Parser.parse (C: \ Users \ shubham-sharma2 \ AppData \ Roaming \ npm \ node_modules \ webpack \ lib \ Parser.js: 902: 15) в NormalModule. (C: \ Users \ shubham-sharma2 \ AppData \ Roaming \ npm \ node_modules \ webpack \ lib \ NormalModule.js: 104: 16) в NormalModule.onModuleBuild (C: \ Users \ shubham-sharma2 \ AppData \ Roaming \ npm \ node_modules \ webpack \ node_modules \ webpack-core \ lib \ NormalModuleMixin.js: 310: 10) в nextLoader (C: \ Users \ shubham-sharma2 \ AppData \ Roaming \ npm \ node_modules \ webpack \ node_modules \ webpack-core \ lib \ NormalModuleMixin.js: 275: 25) в C: \ Users \ shubham-sharma2 \ AppData \ Roaming \ npm \ node_modules \ webpack \ node_modules \ webpack-core \ lib \ NormalModuleMixin.js: 259: 5 в Storage.finished (C: \ Users \ shubham-sharma2 \ AppData \ Roaming \ npm \ node_modules \ webpack \ node_modules \ extended-resolve \ lib \ CachedInputFileSystem.js: 38: 16) в C: \ Users \ shubham-sharma2 \ AppData \ Roaming \ npm \ node_modules \ webpack \ node_modules \ graceful-fs \ graceful-fs.js: 78: 16 в FSReqWrap.readFileAfterClose [как oncomplete] (fs.js: 511: 3) @ multi main
"webpack --config --display-error-details ./webpack.config.js"
const webpack = require('webpack');
const merge = require('webpack-merge');
const path = require('path');
var config = {
entry:path.resolve(__dirname,'src/plugin.js'),
output: {
path: path.resolve( __dirname,'/dist/')
},
module: {
rules: [ {
test: /\.js$/,
loader: 'babel-loader',
include: __dirname,
exclude: /node_modules/
},
{
test: /\.vue$/,
loader: 'vue-loader'
} ]
},resolve: {
extensions: ['.vue', '.js', '.jsx','']
},plugins:[ new webpack.optimize.UglifyJsPlugin( {
minimize : true,
sourceMap : false,
mangle: true,
compress: {
warnings: false
}
} )]
};
config.node = {
fs:'empty'
};
module.exports = [
merge(config, {
entry: path.resolve(__dirname,'src/plugin.js'),
output: {
filename: 'loader.min.js',
libraryTarget: 'window',
library: 'Loader',
}
}),
merge(config, {
entry: path.resolve(__dirname , 'src/Loader.vue'),
output: {
filename: 'loader.js',
libraryTarget: 'umd',
library: 'Loader',
umdNamedDefine: true
}
})
// Config 1: For browser environment
// merge(commonConfig, {
// }),
// Config 2: For Node-based development environments
// merge(commonConfig, {
// })
];
Какая первая строка в src / Loader.vue?
Первая строка @StevenSpungin - это просто открытие <template> </template>





Добавлять
const VueLoaderPlugin = require('vue-loader/lib/plugin')
в верхнюю часть конфигурации вашего веб-пакета и
new VueLoaderPlugin()
в разделе плагинов.
И для ваших блоков стиля добавьте:
// this will apply to both plain `.css` files
// AND `<style>` blocks in `.vue` files
{
test: /\.css$/,
use: [
'vue-style-loader',
'css-loader'
]
}
Вы также можете попробовать:
extensions: ['', '.vue', '.js', '.jsx']
Я видел, как порядок стал проблемой.
Предыдущее решение сработало для меня, проблема заключалась в том, что я не включил const VueLoaderPlugin = require ('vue-loader / lib / plugin') после его добавления сборка создана успешно
спасибо @Steven, после включения стиля с областью видимости блок стиля выполнил свою работу.
Просто трассировка стека бесполезна для людей, которые вам помогают. Опубликуйте конфигурацию веб-пакета, команды, которые вы пытаетесь запустить, фрагмент кода и т. д.