Open fifzteen opened 4 years ago
In vue.config.js, I set up rollup-plugin-replace option, but replacement dosen't work.
const replace = require('rollup-plugin-replace') module.exports = { pluginOptions: { p11n: { configureRollup: { plugins: [ replace({ imgpath: "'../src/assets/logo.png'"}) ] } } } }
<template> <div class="hello"> <img v-bind:src="img"> </div> </template> <script> export default { name: 'HelloWorld', props: { msg: String }, data: function(){ return { img: require(imgpath) } } } </script>
var script = { name: 'HelloWorld', props: { msg: String }, data: function data() { return { img: require(imgpath) <- expected "require('../src/assets/logo.png')" }; } };
(for entire test project, view my repository. https://github.com/fifzteen/p11ntest/tree/master)
I also test to rollup directly. that is working correctly.
import path from 'path' import babel from 'rollup-plugin-babel' import commonjs from 'rollup-plugin-commonjs' import vue from 'rollup-plugin-vue' import replace from 'rollup-plugin-replace' export default [{ input: path.join(__dirname, '.', 'src', 'components', 'HelloWorld.vue'), output: [ { file: 'dist/p11ntest_rollup.esm.js', format: 'es' } ], plugins: [ vue({css: true}), replace({ imgpath: "'../src/assets/logo.png'" }), commonjs(), babel({ exclude: 'node_modules/**', runtimeHelpers: true }), ] }]
var script = { name: 'HelloWorld', props: { msg: String }, data: function data() { return { img: require('../src/assets/logo.png') }; } };
I'm happy to tell me solutions or whether this is a bug or not.
In vue.config.js, I set up rollup-plugin-replace option, but replacement dosen't work.
vue.config.js
input(src/components/HelloWorld.vue)
output(p11ntest.esm.js)
(for entire test project, view my repository. https://github.com/fifzteen/p11ntest/tree/master)
I also test to rollup directly. that is working correctly.
rollup.config.js
output(p11ntest_rollup.sem.js)
I'm happy to tell me solutions or whether this is a bug or not.